Skip to content

Commit

Permalink
Merge branch 'master' into feat-useInfiniteScroll-top
Browse files Browse the repository at this point in the history
  • Loading branch information
crazylxr authored Jul 11, 2024
2 parents 23dfe69 + b2f1218 commit 5ec6d6f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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]);
};
10 changes: 6 additions & 4 deletions packages/hooks/src/useLatest/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
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 5ec6d6f

Please sign in to comment.