From d92f995743242a12830ae85d4356391864ae79fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A3=AB=E5=AD=90=E2=98=80=EF=B8=8F?= <84996057@qq.com> Date: Mon, 8 Jul 2024 21:12:47 +0800 Subject: [PATCH] fix: resolves depsEqual performance issues (#2577) (#2578) --- packages/hooks/src/createDeepCompareEffect/index.ts | 2 +- packages/hooks/src/utils/useDeepCompareWithTarget.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hooks/src/createDeepCompareEffect/index.ts b/packages/hooks/src/createDeepCompareEffect/index.ts index eefdd6b39b..5bbaff74ed 100644 --- a/packages/hooks/src/createDeepCompareEffect/index.ts +++ b/packages/hooks/src/createDeepCompareEffect/index.ts @@ -10,9 +10,9 @@ export const createDeepCompareEffect: CreateUpdateEffect = (hook) => (effect, de const signalRef = useRef(0); if (deps === undefined || !depsEqual(deps, ref.current)) { - ref.current = deps; signalRef.current += 1; } + ref.current = deps; hook(effect, [signalRef.current]); }; diff --git a/packages/hooks/src/utils/useDeepCompareWithTarget.ts b/packages/hooks/src/utils/useDeepCompareWithTarget.ts index 89d685b4dd..2c84ff4e96 100644 --- a/packages/hooks/src/utils/useDeepCompareWithTarget.ts +++ b/packages/hooks/src/utils/useDeepCompareWithTarget.ts @@ -13,9 +13,9 @@ const useDeepCompareEffectWithTarget = ( const signalRef = useRef(0); if (!depsEqual(deps, ref.current)) { - ref.current = deps; signalRef.current += 1; } + ref.current = deps; useEffectWithTarget(effect, [signalRef.current], target); };