algolia / instantsearch

⚑️ Libraries for building performant and instant search experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.

Home Page:https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Routing is not working while a custom onStateChange props is defined

matthieupinte opened this issue Β· comments

πŸ› Current behavior

When we define a custom onStateChange props, url query params are not "set" on load via routing={true}.
If not, routing={true} works as expected with default query params

At load:

With onStateChange={({ uiState, setUiState}) => setUiState(uiState)} routing
Screenshot 2024-03-15 at 09 32 59

With routing
Screenshot 2024-03-15 at 09 33 51

Seems related to #4795

CodeSandbox sample:
https://codesandbox.io/p/sandbox/hungry-borg-tkntsx?file=%2Fsrc%2FApp.tsx

πŸ” Steps to reproduce

  1. Set a <InstantSearch routing> component in your page, with some widgets like refinementList or other
  2. Set a initialUiState props (ex: initialUiState={{ 'YOUR_INDEX': { refinementList: { ATTRIBUTE: ['VALUE'] } }}
  3. Set a custom onStateChange={({ uiState, setUiState }) => setUiState(uiState)} props

Live reproduction

https://codesandbox.io/

πŸ’­ Expected behavior

We expect to see url params reflecting our uiState, even if we set a custom onStateChange props on InstantSearch component.

Package version

react-instantsearch v7.7.0

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct