From e065ee6fcdece3e4b8047542c743caa10da2d9b4 Mon Sep 17 00:00:00 2001 From: daishi Date: Thu, 14 Mar 2024 10:37:22 +0900 Subject: [PATCH] [v2] fix: make affected per proxy --- src/react.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/react.ts b/src/react.ts index ec7077ca..c219da16 100644 --- a/src/react.ts +++ b/src/react.ts @@ -110,8 +110,9 @@ export function useSnapshot( options?: Options, ): Snapshot { const notifyInSync = options?.sync - // per-hook affected, it's not ideal but memo compatible - const affected = useMemo(() => new WeakMap(), []) + // per-proxy & per-hook affected, it's not ideal but memo compatible + // eslint-disable-next-line react-hooks/exhaustive-deps + const affected = useMemo(() => new WeakMap(), [proxyObject]) const lastSnapshot = useRef>() let inRender = true const currSnapshot = useSyncExternalStore(