Skip to content

Commit 8cf538c

Browse files
authored
Merge pull request #1966 from ethen001/chores/custom-equality-fn-docs
2 parents 70a167e + 54d8096 commit 8cf538c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/api/hooks.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ import { shallowEqual, useSelector } from 'react-redux'
100100
const selectedData = useSelector(selectorReturningObject, shallowEqual)
101101
```
102102

103+
- Use a custom equality function as the `equalityFn` argument to `useSelector()`, like:
104+
105+
```js
106+
import { useSelector } from 'react-redux'
107+
108+
// equality function
109+
const customEqual = (oldValue, newValue) => oldValue === newValue
110+
111+
// later
112+
const selectedData = useSelector(selectorReturningObject, customEqual)
113+
```
114+
103115
The optional comparison function also enables using something like Lodash's `_.isEqual()` or Immutable.js's comparison capabilities.
104116

105117
### `useSelector` Examples

0 commit comments

Comments
 (0)