Skip to content

Commit

Permalink
[beta] fix: cleanup resize listener (#4847)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanpriyan committed Oct 4, 2022
1 parent 45e3c1b commit 3a9b0c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions beta/src/components/MDX/Challenges/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export function Navigation({

useEffect(() => {
handleResize();
window.addEventListener('resize', debounce(handleResize, 200));
const debouncedHandleResize = debounce(handleResize, 200);
window.addEventListener('resize', debouncedHandleResize);
return () => {
window.removeEventListener('resize', handleResize);
window.removeEventListener('resize', debouncedHandleResize);
};
}, [handleResize]);

Expand Down

0 comments on commit 3a9b0c8

Please sign in to comment.