Skip to content

Commit

Permalink
useReducedMotion hook: guard the reference to window (#17165)
Browse files Browse the repository at this point in the history
Fixes a bug where a naked reference to `window` will crash if used in a SSR
context where there's no `window`.
  • Loading branch information
jsnajdr authored and gziolo committed Aug 27, 2019
1 parent 4d0d290 commit 9c58193
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/compose/src/hooks/use-reduced-motion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import useMediaQuery from '../use-media-query';
*
* @type {boolean}
*/
const IS_IE = window.navigator.userAgent.indexOf( 'Trident' ) >= 0;
const IS_IE =
typeof window !== 'undefined' &&
window.navigator.userAgent.indexOf( 'Trident' ) >= 0;

/**
* Hook returning whether the user has a preference for reduced motion.
Expand Down

0 comments on commit 9c58193

Please sign in to comment.