selector()
The selector
methods allow you to create reusable selectors that can compute derived state with optional parameters. Selectors are required when creating a store, even if empty.
Inside Components (useSelector)
Use the useSelector
for reactive state in components:
Outside Components (getSelector)
Use the getSelector
for non-reactive state access:
Type Safety
Selectors are fully type-safe. TypeScript will ensure that:
- The selector exists in your store's selectors
- The parameter type matches the selector's expected parameter type
- The return type matches the selector's defined return type