Skip to content

Commit 81d2296

Browse files
committed
Connect: pass ownProps to areStatesEqual
1 parent fee8190 commit 81d2296

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/api/connect.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ When `options.pure` is true, `connect` performs several equality checks that are
236236
237237
We provide a few examples in the following sections.
238238
239-
#### `areStatesEqual: (next: Object, prev: Object) => boolean`
239+
#### `areStatesEqual: (next: Object, prev: Object, nextOwnProps: Object, prevOwnProps: Object) => boolean`
240240
241241
- default value: `strictEqual: (next, prev) => prev === next`
242242
@@ -249,7 +249,7 @@ const areStatesEqual = (next, prev) =>
249249
prev.entities.todos === next.entities.todos
250250
```
251251
252-
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.
252+
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.
253253
254254
_Example 2_
255255

src/connect/selectorFactory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function pureFinalPropsSelectorFactory(
7373

7474
function handleSubsequentCalls(nextState, nextOwnProps) {
7575
const propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps)
76-
const stateChanged = !areStatesEqual(nextState, state)
76+
const stateChanged = !areStatesEqual(nextState, state, nextOwnProps, ownProps)
7777
state = nextState
7878
ownProps = nextOwnProps
7979

0 commit comments

Comments
 (0)