diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 48d0a91098..4e2d7adeb7 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -21,7 +21,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: pnpm run intall, build + - name: pnpm run install, build run: | pnpm run init env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73f3a5c7c9..18eeb7bbe4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: pnpm run intall, build + - name: pnpm run install, build run: | pnpm run init 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/useLatest/__tests__/index.test.ts b/packages/hooks/src/useLatest/__tests__/index.test.ts index 74044703ed..04ad36c4ec 100644 --- a/packages/hooks/src/useLatest/__tests__/index.test.ts +++ b/packages/hooks/src/useLatest/__tests__/index.test.ts @@ -18,11 +18,13 @@ describe('useLatest', () => { }); it('useLatest with reference variable should work', async () => { - const { result, rerender } = setUp({}); + const val1 = {}; + const { result, rerender } = setUp(val1); - expect(result.current.current).toEqual({}); + expect(result.current.current).toBe(val1); - rerender([]); - expect(result.current.current).toEqual([]); + const val2 = []; + rerender(val2); + expect(result.current.current).toBe(val2); }); }); 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); };