Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Dec 19, 2020
2 parents e9b1177 + 6c3c8bb commit d3c2127
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/useTrackedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export const useTrackedState = <State>(
/* eslint-enable no-nested-ternary, indent, no-multi-spaces */
);
const affected = new WeakMap();
const lastAffected = useRef<WeakMap<Record<string, unknown>, unknown>>();
const prevState = useRef<State | null>(null);
const lastState = useRef<State | null>(null);
const lastAffected = useRef<typeof affected>();
const prevState = useRef<State>();
const lastState = useRef<State>();
useIsomorphicLayoutEffect(() => {
lastAffected.current = affected;
if (prevState.current !== lastState.current
Expand All @@ -71,7 +71,7 @@ export const useTrackedState = <State>(
const deepChangedCache = new WeakMap();
return (nextState: State) => {
lastState.current = nextState;
if (prevState.current !== null
if (prevState.current
&& prevState.current !== nextState
&& lastAffected.current
&& !isDeepChanged(
Expand Down

0 comments on commit d3c2127

Please sign in to comment.