You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ function mapStateToProps(state) {
92
92
// component will receive: props.a, props.todos, and props.filter
93
93
```
94
94
95
-
> Note: In advanced scenarios where you need more control over the rendering performance, `mapStateToProps` can also return a function. In this case, that function will be used as the final `mapStateToProps` for a particular component instance. This allows you to do per-instance memoization. See the [Advanced Usage]() section of the docs for more details, as well as [PR #279](https://github.com/reduxjs/react-redux/pull/279) and the tests it adds. Most apps never need this.
95
+
> Note: In advanced scenarios where you need more control over the rendering performance, `mapStateToProps` can also return a function. In this case, that function will be used as the final `mapStateToProps` for a particular component instance. This allows you to do per-instance memoization. See the [Advanced Usage: Factory Functions](../api/connect.md) section of the docs for more details, as well as [PR #279](https://github.com/reduxjs/react-redux/pull/279) and the tests it adds. Most apps never need this.
96
96
97
97
## Usage Guidelines
98
98
@@ -102,7 +102,7 @@ function mapStateToProps(state) {
102
102
103
103
### Use Selector Functions to Extract and Transform Data
104
104
105
-
We highly encourage the use of "selector" functions to help encapsulate the process of extracting values from specific locations in the state tree. Memoized selector functions also play a key role in improving application performance (see the following sections in this page and the [Advanced Usage: Performance]() page for more details on why and how to use selectors.)
105
+
We highly encourage the use of "selector" functions to help encapsulate the process of extracting values from specific locations in the state tree. Memoized selector functions also play a key role in improving application performance (see the following sections in this page and the [Advanced Usage: Computing Derived Data](https://redux.js.org/recipes/computing-derived-data) page for more details on why and how to use selectors.)
106
106
107
107
### `mapStateToProps` Functions Should Be Fast
108
108
@@ -139,7 +139,7 @@ Many common operations result in new object or array references being created:
139
139
- Copying values with `Object.assign`
140
140
- Copying values with the spread operator `{ ...oldState, ...newData }`
141
141
142
-
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.
142
+
Put these operations in [memoized selector functions](https://redux.js.org/recipes/computing-derived-data#creating-a-memoized-selector) 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.
143
143
144
144
### Only Perform Expensive Operations When Data Changes
0 commit comments