You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are encountering a compatibility issue with the react-instantsearch-nextjs experimental package.
I had the below warning in the console.
The issue arises when I try to resolve this console message from the package:
Starting from the next major version, InstantSearch will not clean up the URL from active refinements when it is disposed.
We recommend setting `cleanUrlOnDispose` to false to adopt this change today.
To stay with the current behaviour and remove this warning, set the option to true.
Which I removed by setting the cleanUrlOnDispose=false.
I try to follow the steps in the docs link that is shared in this log message here.
However, I don't seem to be able to pass the history object or next/router singleton object (deprecated?) in the experimental package's routing prop that is required when passing a cleanUrlOnDispose argument.
What I have done
My current set up is as follow. My component is nested within a client component so I'm not on the server side.
<InstantSearchNext
searchClient={algoliaClient}
indexName={ALGOLIA_SUPPLIER_INDEX}
routing={{
router: { cleanUrlOnDispose: false },
}}
future={{
preserveSharedStateOnUnmount: true,
}}
>
<AlgoliaCustomHookProvider>
<Configure
analytics={true}
clickAnalytics={true}
userToken={user?.uuid || undefined} // TODO: get the ananymousID from segment when anonymous
/>
<SearchMarketplace formattedMaterials={formattedMaterialsJSON} type={type} />
</AlgoliaCustomHookProvider>
</InstantSearchNext>
The warning is gone. By anywhere the component is loaded, my URL is going to be rewritten if it contains parameters that are not known by Algolia (eg test=true).
Could you shed some light?
The text was updated successfully, but these errors were encountered:
dhayab
transferred this issue from algolia/algoliasearch-client-javascript
Apr 11, 2024
Hi, cleanUrlOnDispose only acts when the InstantSearch component is unmounted, so it isn't related to what you're experiencing.
Because InstantSearch takes over the URL when routing is enabled to store its search state in it, it doesn't allow unrelated query parameters within it by default. If you want to keep them, you need to explicitly include them by overriding the createURL router method. Here's a simple example you can use as a basis for your needs:
Hi @dhayab, do you have a more detailed version or code sandbox set up with this kind of example. I am trying to implement a similar case where the user can change index by clicking on different tabs. Very similar to this example but with InstantSearchNext. I keep running into the problem of the router removing the extra parameter.
Environment:
Actual
We are encountering a compatibility issue with the react-instantsearch-nextjs experimental package.
I had the below warning in the console.
Which I removed by setting the cleanUrlOnDispose=false.
I try to follow the steps in the docs link that is shared in this log message here.
However, I don't seem to be able to pass the history object or
next/router
singleton object (deprecated?) in the experimental package's routing prop that is required when passing a cleanUrlOnDispose argument.What I have done
My current set up is as follow. My component is nested within a client component so I'm not on the server side.
The warning is gone. By anywhere the component is loaded, my URL is going to be rewritten if it contains parameters that are not known by Algolia (eg
test=true
).Could you shed some light?
The text was updated successfully, but these errors were encountered: