React · Senior · Question 34 of 75
Why don't you put promises, class instances and functions into the Redux store?
- ✓Correct answer: It breaks serialization, DevTools, state persistence and predictability
- 2Redux physically can't store anything but strings and numbers
- 3It slows
useSelectordozens of times due to deep comparison
Explanation
The store should be a plain serializable tree: it's logged, persisted (redux-persist), replayed in time travel and passed from the server during SSR. RTK warns about non-serializable values in dev. Keep non-serializable objects outside the store and store their ids in it.