1

React InstantSearch is not persisting when results are clicked and sate is updated. I am using custom hits results with React InstantSearch connected to Algolia.

All components are custom defined outside the InstantSearch component on the page. Any time there is an action to the custom hit component calling a function the search state resets and results are cleared. I want results to persist so that they can be viewed in detail and saved.

  • Have you tried using local state? – Jevon Cochran Jan 09 '22 at 17:49
  • I have am using useSate hook to update with the selected "hit" to display it in a side panel. The main issue is the searchState keeps re-rendering when anything is called. const [selectedHit, setSelectedHit] = useState(null); – Peter Mangan Jan 09 '22 at 18:58
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 18 '22 at 01:28
  • I've seen this happening if the logic in your React component removes refinement components from the DOM. In my case filters were inside a drawer, which when closed would get removed from the DOM, toggle it on and off would cause Algolia to always reset the search state. – Luis Martins May 23 '22 at 11:18

0 Answers0