File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -131,10 +131,11 @@ export function useSnapshot<T extends object>(
131131 [ proxyObject ] ,
132132 )
133133 const lastSnapshot = useRef < Snapshot < T > > ( undefined )
134- let inRender = true
134+ const subscribed = useRef ( false )
135135 const currSnapshot = useSyncExternalStore (
136136 useCallback (
137137 ( callback ) => {
138+ subscribed . current = true
138139 const unsub = subscribe ( proxyObject , callback , notifyInSync )
139140 callback ( ) // Note: do we really need this?
140141 return unsub
@@ -145,7 +146,7 @@ export function useSnapshot<T extends object>(
145146 const nextSnapshot = snapshot ( proxyObject )
146147 try {
147148 if (
148- ! inRender &&
149+ subscribed . current &&
149150 lastSnapshot . current &&
150151 ! isChanged (
151152 lastSnapshot . current ,
@@ -164,9 +165,6 @@ export function useSnapshot<T extends object>(
164165 } ,
165166 ( ) => snapshot ( proxyObject ) ,
166167 )
167- // TODO how could we bypass this?
168- // eslint-disable-next-line react-hooks/immutability
169- inRender = false
170168 useLayoutEffect ( ( ) => {
171169 lastSnapshot . current = currSnapshot
172170 } )
You can’t perform that action at this time.
0 commit comments