What are the main building blocks of Redux (Actions, Reducers, Store)?
Redux is built on three main building blocks:
-
Actions
Actions are plain JavaScript objects that describe what happened.
Example:{ type: 'INCREMENT' }
-
Reducers
Reducers are pure functions that take the current state and an action as arguments and return a new state.
Example:function counterReducer(state = 0, action) { switch (action.type) { case 'INCREMENT': return state + 1; case 'DECREMENT': return state - 1; default: return state; } }
-
Store
The store holds the application state. It brings Actions and Reducers together.
It provides methods likedispatch(action)
,getState()
, andsubscribe(listener)
.
These three pieces work together in a unidirectional flow to manage state consistently across your app.