Skip to content

Commit dcf2cb0

Browse files
tobhulttimdorr
authored andcommitted
Check if window.document.createElement exists to determine if rendering on server or not (#1283)
1 parent dec00a8 commit dcf2cb0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/connectAdvanced.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ const initStateUpdates = () => [null, 0]
3838
// `connect` to perform sync updates to a ref to save the latest props after
3939
// a render is actually committed to the DOM.
4040
const useIsomorphicLayoutEffect =
41-
typeof window !== 'undefined' ? useLayoutEffect : useEffect
41+
typeof window !== 'undefined' &&
42+
typeof window.document !== 'undefined' &&
43+
typeof window.document.createElement !== 'undefined'
44+
? useLayoutEffect
45+
: useEffect
4246

4347
export default function connectAdvanced(
4448
/*

0 commit comments

Comments
 (0)