Skip to content

Commit

Permalink
[v2] fix: make affected per proxy (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Mar 15, 2024
1 parent a8e4452 commit c04346d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ export function useSnapshot<T extends object>(
options?: Options,
): Snapshot<T> {
const notifyInSync = options?.sync
// per-hook affected, it's not ideal but memo compatible
const affected = useMemo(() => new WeakMap<object, unknown>(), [])
// 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<object, unknown>(), [proxyObject])
const lastSnapshot = useRef<Snapshot<T>>()
let inRender = true
const currSnapshot = useSyncExternalStore(
Expand Down

0 comments on commit c04346d

Please sign in to comment.