File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
libs/isograph-react-disposable-state/src Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ export function useCachedResponsivePrecommitValue<T>(
51
51
const lastCommittedParentCache = useRef < ParentCache < T > | null > ( null ) ;
52
52
53
53
useEffect ( ( ) => {
54
+ // react reruns all `useEffect` in HMR since it doesn't know if the
55
+ // code inside of useEffect has changed. Since this is a library
56
+ // user can't change this code so we are safe to skip this rerun.
57
+ // This also prevents `useEffect` from running twice in Strict Mode.
54
58
if ( lastCommittedParentCache . current === parentCache ) {
55
59
return ;
56
60
}
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ export function useLazyDisposableState<T>(
32
32
33
33
const lastCommittedParentCache = useRef < ParentCache < T > | null > ( null ) ;
34
34
useEffect ( ( ) => {
35
+ // react reruns all `useEffect` in HMR since it doesn't know if the
36
+ // code inside of useEffect has changed. Since this is a library
37
+ // user can't change this code so we are safe to skip this rerun.
38
+ // This also prevents `useEffect` from running twice in Strict Mode.
35
39
if ( lastCommittedParentCache . current === parentCache ) {
36
40
return ;
37
41
}
You can’t perform that action at this time.
0 commit comments