diff --git a/src/modules/emote_menu/components/Button.jsx b/src/modules/emote_menu/components/Button.jsx index ebb69707d5..396979ee59 100644 --- a/src/modules/emote_menu/components/Button.jsx +++ b/src/modules/emote_menu/components/Button.jsx @@ -28,16 +28,19 @@ export default function Button({ ]); useEffect(() => { - const callback = () => { + function callback() { setLoaded(true); - }; + } if (loaded || emoteMenuViewStore.isLoaded()) { callback(); - return; + return null; } - emoteMenuViewStore.once('updated', callback); + const removeListener = emoteMenuViewStore.once('updated', callback); + return () => { + removeListener(); + }; }, []); useEffect(() => { diff --git a/src/modules/emote_menu/hooks/HorizontalResize.jsx b/src/modules/emote_menu/hooks/HorizontalResize.jsx index 42bfae5f39..2e2fc99c80 100644 --- a/src/modules/emote_menu/hooks/HorizontalResize.jsx +++ b/src/modules/emote_menu/hooks/HorizontalResize.jsx @@ -33,8 +33,9 @@ export default function useHorizontalResize({boundingQuerySelector, handleRef, r } React.useEffect(() => { - if (handleRef.current == null) { - return undefined; + const currentRef = handleRef.current; + if (currentRef == null) { + return null; } function handleWindowResize() { @@ -52,14 +53,12 @@ export default function useHorizontalResize({boundingQuerySelector, handleRef, r handleWindowResize(); - handleRef.current.addEventListener('mousedown', handleResizeStart); + currentRef.addEventListener('mousedown', handleResizeStart); document.addEventListener('mouseup', handleResizeEnd); window.addEventListener('resize', handleWindowResize); return () => { - if (handleRef.current != null) { - handleRef.current.removeEventListener('mousedown', handleResizeStart); - } + currentRef.removeEventListener('mousedown', handleResizeStart); document.addEventListener('mouseup', handleResizeEnd); window.removeEventListener('resize', handleWindowResize); };