Skip to content

Commit

Permalink
chore(docs): added custom equalityFn example
Browse files Browse the repository at this point in the history
  • Loading branch information
Enger Then committed Oct 28, 2022
1 parent 70a167e commit 54d8096
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/api/hooks.md
Original file line number Diff line number Diff line change
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 54d8096

Please sign in to comment.