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/api/hooks.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ Allows you to extract data from the Redux store state, using a selector function
40
40
41
41
> **Note**: The selector function should be [pure](https://en.wikipedia.org/wiki/Pure_function) since it is potentially executed multiple times and at arbitrary points in time.
42
42
43
-
The selector is approximately equivalent to the [`mapStateToProps` argument to `connect`](../using-react-redux/connect-extracting-data-with-mapStateToProps.md) conceptually. The selector will be called with the entire Redux store state as its only argument. The selector will be run whenever the function component renders. `useSelector()` will also subscribe to the Redux store, and run your selector whenever an action is dispatched.
43
+
The selector is approximately equivalent to the [`mapStateToProps` argument to `connect`](../using-react-redux/connect-extracting-data-with-mapStateToProps.md) conceptually. The selector will be called with the entire Redux store state as its only argument. The selector will be run whenever the function component renders (unless its reference hasn't changed since a previous render of the component so that a cached result can be returned by the hook without re-running the selector). `useSelector()` will also subscribe to the Redux store, and run your selector whenever an action is dispatched.
44
44
45
45
However, there are some differences between the selectors passed to `useSelector()` and a `mapState` function:
46
46
@@ -57,7 +57,7 @@ You may call `useSelector()` multiple times within a single function component.
57
57
### Equality Comparisons and Updates
58
58
59
59
When the function component renders, the provided selector function will be called and its result will be returned
60
-
from the `useSelector()` hook. (A cached result may be returned if the selector has been run and hasn't changed.)
60
+
from the `useSelector()` hook. (A cached result may be returned by the hook without re-running the selector if it's the same function reference as on a previous render of the component.)
61
61
62
62
However, when an action is dispatched to the Redux store, `useSelector()` only forces a re-render if the selector result
63
63
appears to be different than the last result. As of v7.1.0-alpha.5, the default comparison is a strict `===` reference
Copy file name to clipboardExpand all lines: website/versioned_docs/version-7.1/api/hooks.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ Allows you to extract data from the Redux store state, using a selector function
41
41
42
42
> **Note**: The selector function should be [pure](https://en.wikipedia.org/wiki/Pure_function) since it is potentially executed multiple times and at arbitrary points in time.
43
43
44
-
The selector is approximately equivalent to the [`mapStateToProps` argument to `connect`](../using-react-redux/connect-extracting-data-with-mapStateToProps.md) conceptually. The selector will be called with the entire Redux store state as its only argument. The selector will be run whenever the function component renders. `useSelector()` will also subscribe to the Redux store, and run your selector whenever an action is dispatched.
44
+
The selector is approximately equivalent to the [`mapStateToProps` argument to `connect`](../using-react-redux/connect-extracting-data-with-mapStateToProps.md) conceptually. The selector will be called with the entire Redux store state as its only argument. The selector will be run whenever the function component renders (unless its reference hasn't changed since a previous render of the component so that a cached result can be returned by the hook without re-running the selector). `useSelector()` will also subscribe to the Redux store, and run your selector whenever an action is dispatched.
45
45
46
46
However, there are some differences between the selectors passed to `useSelector()` and a `mapState` function:
47
47
@@ -58,7 +58,7 @@ You may call `useSelector()` multiple times within a single function component.
58
58
### Equality Comparisons and Updates
59
59
60
60
When the function component renders, the provided selector function will be called and its result will be returned
61
-
from the `useSelector()` hook. (A cached result may be returned if the selector has been run and hasn't changed.)
61
+
from the `useSelector()` hook. (A cached result may be returned by the hook without re-running the selector if it's the same function reference as on a previous render of the component.)
62
62
63
63
However, when an action is dispatched to the Redux store, `useSelector()` only forces a re-render if the selector result
64
64
appears to be different than the last result. As of v7.1.0-alpha.5, the default comparison is a strict `===` reference
0 commit comments