State Management · Junior · Question 56 of 75
Why define selector functions like selectCartTotal(state) instead of inline lookups everywhere?
- ✓Correct answer: Components don't depend on the state shape, logic lives in one place and selectors can be memoized
- 2Redux requires all selectors to be named
- 3Inline selectors don't work with
useSelector
Explanation
When the state structure changes, only the selectors need updating. createSelector adds memoization for derived data.