State Management · Middle · Question 53 of 75
Should you store cartTotal in the Redux state next to items?
- ✓Correct answer: No - derive it with a (memoized) selector from
items - 2Yes - and update it in every reducer that changes items
- 3Yes - derived values must live in the store
Explanation
Duplicated derived data drifts out of sync. Keep the minimal state and compute the rest in selectors, as the Redux style guide recommends.