File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export * from "./getPercentage";
2323export * from "./nearest" ;
2424
2525export * from "./useEnsuredRef" ;
26+ export * from "./useIsomorphicLayoutEffect" ;
2627export { default as useToggle } from "./useToggle" ;
2728export { default as useInterval } from "./useInterval" ;
2829export { 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