Skip to content

Commit

Permalink
Merge pull request #1966 from ethen001/chores/custom-equality-fn-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Oct 28, 2022
2 parents 70a167e + 54d8096 commit 8cf538c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/api/hooks.md
Expand Up @@ -100,6 +100,18 @@ import { shallowEqual, useSelector } from 'react-redux'
const selectedData = useSelector(selectorReturningObject, shallowEqual)
```

- Use a custom equality function as the `equalityFn` argument to `useSelector()`, like:

```js
import { useSelector } from 'react-redux'

// equality function
const customEqual = (oldValue, newValue) => oldValue === newValue

// later
const selectedData = useSelector(selectorReturningObject, customEqual)
```

The optional comparison function also enables using something like Lodash's `_.isEqual()` or Immutable.js's comparison capabilities.

### `useSelector` Examples
Expand Down

0 comments on commit 8cf538c

Please sign in to comment.