File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export * from "./getPercentage";
23
23
export * from "./nearest" ;
24
24
25
25
export * from "./useEnsuredRef" ;
26
+ export * from "./useIsomorphicLayoutEffect" ;
26
27
export { default as useToggle } from "./useToggle" ;
27
28
export { default as useInterval } from "./useInterval" ;
28
29
export { default as useTimeout } from "./useTimeout" ;
Original file line number Diff line number Diff line change
1
+ import { useEffect , useLayoutEffect } from "react" ;
2
+
3
+ /**
4
+ * This is copy/pasted from react-redux which has some more information about
5
+ * this and how to fix "invalid" warnings while running tests.
6
+ *
7
+ * @see https://github.com/reduxjs/react-redux/blob/4c907c0870c6b9a136dd69be294c17d1dc63c8f5/src/utils/useIsomorphicLayoutEffect.js
8
+ */
9
+ export const useIsomorphicLayoutEffect =
10
+ typeof window !== "undefined" &&
11
+ typeof window . document !== "undefined" &&
12
+ typeof window . document . createElement !== "undefined"
13
+ ? useLayoutEffect
14
+ : useEffect ;
You can’t perform that action at this time.
0 commit comments