-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[react-instantsearch-hooks] Virtual widget state getting cleared on unmounting of Original Refinement List #6558
Comments
Your sandbox is private so I can't see everything, but I think what's missing in that documentation is the |
Yeah sorry, I have made it public now https://codesandbox.io/p/sandbox/mvkzz9. Can you see if you can access it now? I didn't set I can see this was the first solution mentioned in the doc |
Solution 3 is the one that was written before preserveSharedStateOnUnmount existed, it should work as well, but will work better in conjunction with solution one (and you won't technically need to store the ui state anymore). I'm not fully sure yet why your sandbox doesn't work, the save in the ui state should work alone, except if possibly the cleanup of the widgets somehow gets done later than the "reset on unmount" you have implemented with ui state |
@Haroenv For my solution, I actually directly copied the code available in the docs, don't know what's the issue. Should I keep this issue open as to figure out why Sol#3 is not working on its own? |
Yes, let's keep this issue open and I'll see if the solution in the docs need to be removed or can be fixed |
🐛 Current behavior
I have created a
VirtualFilters
to useuseRefinementList
, to store the state of the applied filters.The filters are displayed inside a modal. When the modal closes, the
CurrentRefinements
resets its value to default.I have followed the exact code as given in the official docs - Persist State on Unmount
I have checked the other issue related to this ISSUE : 5240, but I want this to work with the
virtual widgets
if possible.Can you please tell me, if I am making a mistake somewhere?
🔍 Steps to reproduce
CodeSandbox
Live reproduction
https://mvkzz9.csb.app/
💭 Expected behavior
When I close the
Filters
modal, theCurrentRefinements
should not reset, but persist the state of the updated filters.This should happen, since I have created a
VirtualFilters
component to store the state as well, which doesn't get unmounted.Package version
algoliasearch: 5.11.0, react-instantsearch": 7.13.6
Operating system
MacOS 15.3.1
Browser
Edge 132.0.2957.140
Code of Conduct
The text was updated successfully, but these errors were encountered: