Skip to content

Commit 6fcfdc2

Browse files
committed
Consistent naming for mapStateToProps
1 parent b245f83 commit 6fcfdc2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ This function should be passed as the first argument to `connect`, and will be c
2828
2929
### Arguments
3030
31+
1. **`state`**
32+
2. **`ownProps` (optional)**
33+
3134
#### `state`
3235
3336
The first argument to a `mapStateToProps` function is the entire Redux store state (the same value returned by a call to `store.getState()`). Because of this, the first argument is traditionally just called `state`. (While you can give the argument any name you want, calling it `store` would be incorrect - it's the "state value", not the "store instance".)
@@ -131,13 +134,13 @@ To summarize the behavior of the component wrapped by `connect` with `mapStateTo
131134
132135
| | `(state) => stateProps` | `(state, ownProps) => stateProps` |
133136
| ---------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------------- |
134-
| `mapStateToProps` runs when: | store `state` changes | store `state` changes <br /> or <br />any field of `ownProps` is different |
137+
| `mapStateToProps` runs when: | store `state` changes | store `state` changes <br /> or <br />any field of `ownProps` is different |
135138
| component re-renders when: | any field of `stateProps` is different | any field of `stateProps` is different <br /> or <br /> any field of `ownProps` is different |
136139
137140
138141
### Only Return New Object References If Needed
139142
140-
React-Redux does shallow comparisons to see if the `mapState` results have changed. It’s easy to accidentally return new object or array references every time, which would cause your component to re-render even if the data is actually the same.
143+
React-Redux does shallow comparisons to see if the `mapStateToProps` results have changed. It’s easy to accidentally return new object or array references every time, which would cause your component to re-render even if the data is actually the same.
141144
142145
Many common operations result in new object or array references being created:
143146
@@ -147,7 +150,7 @@ Many common operations result in new object or array references being created:
147150
- Copying values with `Object.assign`
148151
- Copying values with the spread operator `{ ...oldState, ...newData }`
149152
150-
Put these operations in [memoized selector functions]() to ensure that they only run if the input values have changed. This will also ensure that if the input values _haven't_ changed, `mapState` will still return the same result values as before, and `connect` can skip re-rendering.
153+
Put these operations in [memoized selector functions]() to ensure that they only run if the input values have changed. This will also ensure that if the input values _haven't_ changed, `mapStateToProps` will still return the same result values as before, and `connect` can skip re-rendering.
151154
152155
153156

0 commit comments

Comments
 (0)