We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 66bced3 commit 0671180Copy full SHA for 0671180
components/Search/Search.tsx
@@ -57,14 +57,12 @@ export const Search = ({
57
},
58
}), [algoliaClient]);
59
60
- console.log('Search component rendered');
61
-
+ // This is a workaround to reset the InstantSearch state when the component is unmounted and remounted,
+ // which can happen when navigating between pages in Next.js. By changing the key of the
62
+ // InstantSearch component, we force it to reset its state.
63
useEffect(() => {
- console.log('Search component mounted');
64
+ // eslint-disable-next-line react-hooks/set-state-in-effect
65
setKey(`search-component-${Date.now()}`);
- return () => {
66
- console.log('Search component unmounted');
67
- };
68
}, []);
69
70
return (
0 commit comments