react-instantsearch icon indicating copy to clipboard operation
react-instantsearch copied to clipboard

Ability to persist a widget

Open mthuret opened this issue 9 years ago • 5 comments

Use case

You have a mobile app using React Native and you want to use a modal to display some filters. When this modal is closed, the widgets that sets the refinements are unmounted, therefore, they're not in the state anymore. see: https://github.com/algolia/instantsearch.js/issues/2069

Need

Being able to say that a widget is persistent. That way its state will remain and can still be applied if a virtual widget is present.

Proposal

Add a prop isPersistent, that if present will indicate that nothing should happen inside the clean function.

mthuret avatar Apr 11 '17 11:04 mthuret

Another possibility here is to actually use another <InstantSearch> instance inside the modal, and forward the state to the main one. That way, virtual widgets does apply.

mthuret avatar Apr 24 '17 14:04 mthuret

Yes this would be very helpful.

ylac avatar Apr 25 '17 07:04 ylac

I also see this as a problem as I have it set up in the header of my page, and every navigation between pages causes another POST

In turn I have about 2200 requests while dev (out of 100k) which will quickly fill up when it goes live.

I'm thinking about creating a component with it at the top-most parent and passing it down, perhaps it won't re-render when the component itself gets re-rendered, but we'll see how it goes

mclapa avatar Jun 23 '17 20:06 mclapa

@mclapa Thread hijacker, no thread hijacking! We're also having this issue when using filters inside react-modal which unmounts contents on close. The virtual widgets workaround would most likely work but since we're not constrained by mobile SDK here we decided to try the quick old-school pure CSS modal approach instead.

catamphetamine avatar Aug 10 '17 22:08 catamphetamine

I'm closing this as for now I don't have a really good API proposal that would fix everything. Our getting started explains how to get along this, feel free to comment/open a new issue if necessary or if you have a proposal :)

mthuret avatar Oct 09 '17 10:10 mthuret