File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
libs/isograph-react-disposable-state/src Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -54,11 +54,11 @@ export function useDisposableState<T = never>(
5454 return ;
5555 }
5656 lastCommittedParentCache . current = parentCache ;
57- // capture last set pair in a variable
58- const current = itemCleanupPairRef . current ;
57+
5958 return ( ) => {
60- // current is a stale variable
61- current ?. [ 1 ] ( ) ;
59+ if ( itemCleanupPairRef . current !== null ) {
60+ itemCleanupPairRef . current [ 1 ] ( ) ;
61+ }
6262 } ;
6363 } ,
6464 [ parentCache ] ,
Original file line number Diff line number Diff line change @@ -36,11 +36,9 @@ export function useLazyDisposableState<T>(
3636 return ;
3737 }
3838 lastCommittedParentCache . current = parentCache ;
39- // capture last set pair in a variable
40- const current = itemCleanupPairRef . current ;
39+
4140 return ( ) => {
42- // current is a stale variable
43- const cleanupFn = current ?. [ 1 ] ;
41+ const cleanupFn = itemCleanupPairRef . current ?. [ 1 ] ;
4442 // TODO confirm useEffect is called in order.
4543 if ( cleanupFn == null ) {
4644 throw new Error (
You can’t perform that action at this time.
0 commit comments