Skip to content

Commit

Permalink
Update useIsomorphicLayoutEffect check (#1636)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusCenterstrom authored and alexreardon committed Nov 27, 2019
1 parent acb9206 commit 72a24eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/view/use-isomorphic-layout-effect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { useLayoutEffect, useEffect } from 'react';
// `connect` to perform sync updates to a ref to save the latest props after
// a render is actually committed to the DOM.
const useIsomorphicLayoutEffect =
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
typeof window !== 'undefined' &&
typeof window.document !== 'undefined' &&
typeof window.document.createElement !== 'undefined'
? useLayoutEffect
: useEffect;

export default useIsomorphicLayoutEffect;

0 comments on commit 72a24eb

Please sign in to comment.