cancel debounced function on unmount to avoid updating state on an umounted component
Signed-off-by: Morgan Bentell <mbentell@spotify.com>
This commit is contained in:
@@ -82,6 +82,8 @@ export const useShadowRootSelection = (waitMillis: number = 0) => {
|
||||
[shadowRoot, setSelection, waitMillis],
|
||||
);
|
||||
|
||||
useEffect(() => handleSelectionChange.cancel);
|
||||
|
||||
useEffect(() => {
|
||||
window.document.addEventListener('selectionchange', handleSelectionChange);
|
||||
return () =>
|
||||
|
||||
Reference in New Issue
Block a user