Skip to content

Commit

Permalink
refactor: replace lodash/isEqual with react-fast-compare (#2458)
Browse files Browse the repository at this point in the history
* refactor: replace lodash/isEqual with react-fast-compare

* chore: update lock

---------

Co-authored-by: 云泥 <1656081615@qq.com>
  • Loading branch information
guoyunhe and liuyib authored Feb 29, 2024
1 parent dfc55d8 commit e55414b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"intersection-observer": "^0.12.0",
"js-cookie": "^2.x.x",
"lodash": "^4.17.21",
"react-fast-compare": "^3.2.2",
"resize-observer-polyfill": "^1.5.1",
"screenfull": "^5.0.0",
"tslib": "^2.4.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useDeepCompareEffect/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nav:

# useDeepCompareEffect

Usage is the same as `useEffect`, but deps are compared with [lodash.isEqual](https://lodash.com/docs/4.17.15#isEqual).
Usage is the same as `useEffect`, but deps are compared with [react-fast-compare](https://www.npmjs.com/package/react-fast-compare).

## Examples

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useDeepCompareEffect/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nav:

# useDeepCompareEffect

用法与 useEffect 一致,但 deps 通过 [lodash isEqual](https://lodash.com/docs/4.17.15#isEqual) 进行深比较。
用法与 useEffect 一致,但 deps 通过 [react-fast-compare](https://www.npmjs.com/package/react-fast-compare) 进行深比较。

## 代码演示

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nav:

# useDeepCompareLayoutEffect

Usage is the same as `useLayoutEffect`, but deps are compared with [lodash.isEqual](https://lodash.com/docs/4.17.15#isEqual).
Usage is the same as `useLayoutEffect`, but deps are compared with [react-fast-compare](https://www.npmjs.com/package/react-fast-compare).

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nav:

# useDeepCompareLayoutEffect

用法与 useLayoutEffect 一致,但 deps 通过 [lodash isEqual](https://lodash.com/docs/4.17.15#isEqual) 进行深比较。
用法与 useLayoutEffect 一致,但 deps 通过 [react-fast-compare](https://www.npmjs.com/package/react-fast-compare) 进行深比较。

## 代码演示

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/utils/depsEqual.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DependencyList } from 'react';
import isEqual from 'lodash/isEqual';
import isEqual from 'react-fast-compare';

export const depsEqual = (aDeps: DependencyList = [], bDeps: DependencyList = []) =>
isEqual(aDeps, bDeps);
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e55414b

Please sign in to comment.