Closed e-krebs closed 1 year ago
Iβm not sure if itβs avoidable, but this should at least be documented somewhere. Who knows where it should go?
as far as I can tell we have this problem in InstantSearch.js too
this issue is a duplicate of: https://github.com/algolia/react-instantsearch/issues/302 This behaviour you're describing is the side-effect of a design choice. I get that it can be annoying in your use case.
Two workarounds I can think of:
connectSearchbox
that doesn't cleanup on unmount. You can probably override the componentWillUnmount here. See: https://github.com/algolia/react-instantsearch/blob/master/packages/react-instantsearch-core/src/core/createConnector.tsx#L186-L213 Let me know if you need help with thatHey!
We're doing a round of clean up before migrating this repository to the new InstantSearch monorepo. This issue seems not to have generated much activity lately. Is it still an issue for you @e-krebs?
I'm not working on the project that had that issue and afaik it's not been reported since. Fine by me to close this
Describe the bug π
You've got two searchboxes on a page. When one is unmounted (even though the other one is still there), an empty refine is triggered.
To Reproduce π Put two search boxes on a page. One is a regular one. One is a custom one (using connectSearchBox) conditionally-rendered when there's no result. It displays a button to do a
refine()
that will display results. When clicking that button, it results on the custom search box being unmounted (since there's results now), which triggers an emptyrefine()
, even though there's still a search box on the page (the regular one).Steps to reproduce the behavior:
Expected behavior π
Do not trigger an empty refine when unmounting a SearchBox. Or at least, do not do so when there's still at lest one SearchBox still mounted.