Skip to content

Commit

Permalink
useBreakpointIndex: attach resize event listener to window inst…
Browse files Browse the repository at this point in the history
…ead of `document`
  • Loading branch information
ciampo committed Aug 5, 2021
1 parent 9e2fc57 commit 7115b6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/components/src/ui/utils/use-responsive-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ export const useBreakpointIndex = (

onResize();

if ( typeof document !== 'undefined' ) {
if ( typeof window !== 'undefined' ) {
// Disable reason: We don't really care about what document we listen to, we just want to know that we're resizing.
/* eslint-disable @wordpress/no-global-event-listener */
document.addEventListener( 'resize', onResize );
window.addEventListener( 'resize', onResize );
}
return () => {
if ( typeof document !== 'undefined' ) {
document.removeEventListener( 'resize', onResize );
if ( typeof window !== 'undefined' ) {
window.removeEventListener( 'resize', onResize );
/* eslint-enable @wordpress/no-global-event-listener */
}
};
Expand Down

0 comments on commit 7115b6d

Please sign in to comment.