Skip to content

Commit

Permalink
make affected per proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Mar 14, 2024
1 parent a740701 commit f777aae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { createProxy, isChanged } from 'proxy-compare';
const targetCache = new WeakMap();

export function useValtio<State extends object>(proxy: State): Snapshot<State> {
// 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
const affected = useMemo(() => new WeakMap<object, unknown>(), [proxy]);
const [[snapshotFromReducer, proxyFromReducer], rerender] = useReducer<
ReducerWithoutAction<readonly [Snapshot<State>, State]>,
undefined
Expand Down

0 comments on commit f777aae

Please sign in to comment.