Skip to content

Commit

Permalink
Suppress console warnings when unmounting refs
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Mar 15, 2021
1 parent c3238b9 commit 7855796
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export default function useInsertionPoint( ref ) {
ref.current.addEventListener( 'mousemove', onMouseMove );

return () => {
ref.current.removeEventListener( 'mousemove', onMouseMove );
ref.current?.removeEventListener( 'mousemove', onMouseMove );
};
}, [ enableMouseMove, onMouseMove ] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function useToolbarFocus(
}
return () => {
window.cancelAnimationFrame( raf );
if ( ! onIndexChange ) return;
if ( ! onIndexChange || ! ref.current ) return;
// When the toolbar element is unmounted and onIndexChange is passed, we
// pass the focused toolbar item index so it can be hydrated later.
const items = getAllToolbarItemsIn( ref.current );
Expand Down

0 comments on commit 7855796

Please sign in to comment.