File tree 1 file changed +0
-41
lines changed
1 file changed +0
-41
lines changed Original file line number Diff line number Diff line change @@ -1324,47 +1324,6 @@ const selectorBad = createSelector(
1324
1324
1325
1325
---
1326
1326
1327
- ## Additional Tips & Tricks
1328
-
1329
- <details ><summary ><b >Top Level Selectors Pattern</b ></summary >
1330
-
1331
- This pattern simplifies the creation of selectors in your application. Start by defining a generic type for your top-level selectors:
1332
-
1333
- ``` ts
1334
- import type { Selector } from ' reselect'
1335
-
1336
- export type TopLevelSelectors <State > = {
1337
- [K in keyof State as K extends string
1338
- ? ` select${Capitalize <K >} `
1339
- : never ]: Selector <State , State [K ], never >
1340
- }
1341
- ` ` `
1342
-
1343
- With this setup, you can easily create top-level selectors for your application's state:
1344
-
1345
- ` ` ` ts
1346
- const topLevelSelectors: TopLevelSelectors <RootState > = {
1347
- selectAlerts : state => state .alerts ,
1348
- selectTodos : state => state .todos ,
1349
- selectUsers : state => state .users
1350
- }
1351
- ```
1352
-
1353
- This approach allows for more streamlined and readable selector creation. For example:
1354
-
1355
- ``` ts
1356
- const selectCompletedTodos = createSelector (
1357
- [topLevelSelectors .selectTodos ],
1358
- todos => todos .filter (todo => todo .completed === true )
1359
- )
1360
- ```
1361
-
1362
- </details >
1363
-
1364
- <div align =" right " >[ <a href =" #table-of-contents " >↑ Back to top ↑</a > ]</div >
1365
-
1366
- ---
1367
-
1368
1327
## FAQ
1369
1328
1370
1329
### Why isn’t my selector recomputing when the input state changes?
You can’t perform that action at this time.
0 commit comments