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
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -313,20 +313,20 @@ There are some differences between the selectors passed to `useSelector()` and a
313
313
314
314
#### No-op selector check
315
315
316
-
In development, a check is conducted on the result returned by the selector. It warns in console if the result is the same as the parameter passed in, i.e. the root state.
316
+
In development, a check is conducted on the result returned by the selector. It warns in the console if the result is the same as the parameter passed in, i.e. the root state.
317
317
318
-
A `useSelector` call returning the entire root state is almost always a mistake, as it means the component will rerender whenever _anything_ in state changes. Selectors should select as specifically as possible.
318
+
A `useSelector` call returning the entire root state is almost always a mistake, as it means the component will rerender whenever _anything_ in state changes. Selectors should be as granular as possible.
319
319
320
320
```ts no-transpile
321
-
// this selector returns the entire state, meaning that the component will rerender unnecessarily
321
+
//BAD: this selector returns the entire state, meaning that the component will rerender unnecessarily
322
322
const { count, user } =useSelector((state) =>state)
323
323
324
-
// instead, select only the state you need, calling useSelector as many times as needed
324
+
//GOOD: instead, select only the state you need, calling useSelector as many times as needed
325
325
const count =useSelector((state) =>state.count)
326
326
const user =useSelector((state) =>state.user)
327
327
```
328
328
329
-
By default, this will only happen when the selector is first called. You can configure the check via context, or per `useSelector` call - either to run the check always, or never.
329
+
By default, this will only happen when the selector is first called. You can configure the check in the Provider or at each `useSelector` call.
0 commit comments