Redux & Redux Toolkit
/Beginner
Redux Best Practices
Definition
The official Style Guide provided by the Redux maintainers, detailing essential rules and highly recommended patterns.
Explain Like I'm New
The 10 Commandments of Redux. Break them, and your app will be slow, buggy, and hard to read. Follow them, and Redux will feel like a superpower.
Real World Example
Rule #1: Do NOT mutate state. Rule #2: Reducers must not have side effects. Rule #3: Do NOT put non-serializable values (like Promises or Functions) in the store.
Common Use Cases
- •Code reviews
- •Onboarding new developers
Terminal Output
bash / terminal
/*
ESSENTIAL REDUX RULES (Do not break these):
1. State must be immutable.
2. Reducers must be pure.
3. State must be serializable (No Maps, Sets, Promises, or Functions).
STRONGLY RECOMMENDED:
1. Use Redux Toolkit exclusively.
2. Use Immer for writing immutable updates.
3. Group code by Feature folders (Ducks pattern).
4. Evaluate selectors using shallowEqual or Reselect.
5. Keep state as flat (normalized) as possible.
*/
Interview Questions
basic
- Can you put a React component (like `<MyIcon />`) into the Redux state tree?
intermediate
- Why does the Style Guide recommend modeling Actions as 'Events' rather than 'Setters'?