Skip to content

Commit 0671180

Browse files
committed
Stability hack.
1 parent 66bced3 commit 0671180

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

components/Search/Search.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ export const Search = ({
5757
},
5858
}), [algoliaClient]);
5959

60-
console.log('Search component rendered');
61-
60+
// This is a workaround to reset the InstantSearch state when the component is unmounted and remounted,
61+
// 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.
6263
useEffect(() => {
63-
console.log('Search component mounted');
64+
// eslint-disable-next-line react-hooks/set-state-in-effect
6465
setKey(`search-component-${Date.now()}`);
65-
return () => {
66-
console.log('Search component unmounted');
67-
};
6866
}, []);
6967

7068
return (

0 commit comments

Comments
 (0)