Skip to content

Commit

Permalink
fix: resolves depsEqual performance issues (#2577) (#2578)
Browse files Browse the repository at this point in the history
  • Loading branch information
caorushizi authored Jul 8, 2024
1 parent d02d146 commit d92f995
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/hooks/src/createDeepCompareEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const createDeepCompareEffect: CreateUpdateEffect = (hook) => (effect, de
const signalRef = useRef<number>(0);

if (deps === undefined || !depsEqual(deps, ref.current)) {
ref.current = deps;
signalRef.current += 1;
}
ref.current = deps;

hook(effect, [signalRef.current]);
};
2 changes: 1 addition & 1 deletion packages/hooks/src/utils/useDeepCompareWithTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const useDeepCompareEffectWithTarget = (
const signalRef = useRef<number>(0);

if (!depsEqual(deps, ref.current)) {
ref.current = deps;
signalRef.current += 1;
}
ref.current = deps;

useEffectWithTarget(effect, [signalRef.current], target);
};
Expand Down

0 comments on commit d92f995

Please sign in to comment.