Skip to content

Commit

Permalink
cancel debounced functions on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
lebalz committed Nov 26, 2024
1 parent 18992c8 commit 6ca5924
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/documents/Excalidoc/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const Editor = observer((props: Props) => {
}, 50);
document.addEventListener('scroll', onscroll);
return () => {
onscroll.cancel();
document.removeEventListener('scroll', onscroll);
};
}, [excalidrawAPI]);
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useIsMobileView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const useIsMobileView = (mobileViewWidth: number = 768) => {
handleResize(); // Initial check

return () => {
handleResize.cancel();
window.removeEventListener('resize', handleResize);
};
}, [mobileViewWidth]);
Expand Down

0 comments on commit 6ca5924

Please sign in to comment.