🌐Redux
Also known as Redux Toolkit, Redux JS, RTK
A JavaScript tool that keeps an app's shared data in one store. It changes by actions.
Think of it like
It is like a bank. You never change the money yourself. You hand in a slip, and the bank does it.
Example
Jack's app has a bug where the cart empties. Redux's tools show every action in order, so he finds the one that did it.
Why it matters
Big apps with lots of shared data stay easy to follow. Every change is written down as an action.
Definition
Example code
javascript
dispatch({ type: "cart/addItem", payload: { id: 7 } });Common mistake
Key takeaways
- 1One store. All shared state in one place.
- 2Actions only. Changes come as small notes.
- 3Reducers decide. A function makes the new state.