Skip to content

Commit

Permalink
Connect: pass ownProps to areStatesEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
jspurlin committed Aug 29, 2022
1 parent fee8190 commit 81d2296
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/api/connect.md
Expand Up @@ -236,7 +236,7 @@ When `options.pure` is true, `connect` performs several equality checks that are
We provide a few examples in the following sections.
#### `areStatesEqual: (next: Object, prev: Object) => boolean`
#### `areStatesEqual: (next: Object, prev: Object, nextOwnProps: Object, prevOwnProps: Object) => boolean`
- default value: `strictEqual: (next, prev) => prev === next`
Expand All @@ -249,7 +249,7 @@ const areStatesEqual = (next, prev) =>
prev.entities.todos === next.entities.todos
```
You may wish to override `areStatesEqual` if your `mapStateToProps` function is computationally expensive and is also only concerned with a small slice of your state. The example above will effectively ignore state changes for everything but that slice of state.
You may wish to override `areStatesEqual` if your `mapStateToProps` function is computationally expensive and is also only concerned with a small slice of your state. The example above will effectively ignore state changes for everything but that slice of state. Additionally, `areStatesEqual` provides `nextOwnProps` and `prevOwnProps` to allow for more effective scoping of your state which your connected component is interested in, if needed.
_Example 2_
Expand Down
2 changes: 1 addition & 1 deletion src/connect/selectorFactory.js
Expand Up @@ -73,7 +73,7 @@ export function pureFinalPropsSelectorFactory(

function handleSubsequentCalls(nextState, nextOwnProps) {
const propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps)
const stateChanged = !areStatesEqual(nextState, state)
const stateChanged = !areStatesEqual(nextState, state, nextOwnProps, ownProps)
state = nextState
ownProps = nextOwnProps

Expand Down

0 comments on commit 81d2296

Please sign in to comment.