Before start understand pillars
Redux complete workflow
React Component
User clicks Increment button
Dispatch
dispatch({ type: "INCREMENT" })
Action
Describes what happened: INCREMENT
Reducer
Receives old state + action and calculates new state
Store
Holds the updated state
Selector
Reads the required data from the store
React Component
Gets updated data and re-renders the UI
Example with count = 0
Step | What happens | Value |
|---|---|---|
1 | User clicks button | Increment |
2 | Dispatch sends action | INCREMENT |
3 | Action is created | INCREMENT |
4 | Reducer calculates | 0 + 1 |
5 | Store updates | count = 1 |
6 | Selector reads state | 1 |
7 | UI displays | Count: 1 |
Remember the sequence:
Component → Dispatch → Action → Reducer → Store → Selector → Component
This is called Redux Unidirectional Data Flow.
Redux Workflow Architecture
React Component
User clicks the Increment button
Dispatch
dispatch({ type: "INCREMENT" })
Action
Describes what happened: INCREMENT
Reducer
Receives previous state + action
Calculates the new state
Store
Holds the updated application state
Selector
Reads required data from the store
React Component
Receives updated data and re-renders UI
Redux follows Unidirectional Data Flow
For more simple expalint we using two story
Story 1: 911 Emergency System 🚨
Imagine an accident happens.
Component: A person reports an accident.
Dispatch: Sends the emergency report.
Action: Describes what happened (accident reported).
Reducer: Processes the report and decides how the incident status changes.
Store: Keeps the current incident information.
Selector: Checks the latest incident status.
Component: Displays the updated status.
Story 2: Pizza Ordering System 🍕
Imagine you order a pizza through an app.
Component: Customer clicks Order Now.
Dispatch: Sends the order request.
Action: Describes the order (one cheese pizza).
Reducer: Processes the order and updates its status.
Store: Keeps order details and status (Preparing).
Selector: Reads the current order status.
Component: Displays "Your pizza is being prepared!"
Easy way to remember
Redux | Simple meaning |
|---|---|
Component | Where user interacts |
Dispatch | Sends information |
Action | What happened |
Reducer | How state changes |
Store | Where state is kept |
Selector | Reads state |
Component | Shows updated result |
Both stories follow the same flow:
Component → Dispatch → Action → Reducer → Store → Selector → Component
Action: The event that happened (e.g., "Need ambulance").
Dispatch: The messenger/trigger (
dispatch(action)) that carries the action into the system to start an update.Reducer: The function that takes
(currentState, action)and calculates the new state. It returns that new state straight to the Store—you don't calldispatchagain to save it.Store: Holds the updated state.
Selector: Picks out just the exact piece of data your UI Component needs (like only the ambulance status), so the component re-renders with the latest info.
The Clean 911 Flow Story
Imaginary story to exampling concept:
It is a busy Tuesday evening inside the Metro 911 Call Center, where the entire city’s emergency response depends on one strict rule: nobody changes the official records directly. At the front desk sits Hannah, our UI Component. Her screen is the face of the operation, displaying live emergency updates and waiting for incoming reports. Suddenly, her headset lights up with an urgent call—there has been a multi-car accident on 5th Avenue, and paramedics are needed immediately.Hannah cannot walk over to the central system and erase or rewrite anything herself. Instead, she types out a clean, standardized emergency ticket labeled"NEED_AMBULANCE"with the exact location, 5th Avenue. In Redux terms, this emergency ticket is the Action. It does not contain any instructions on how to solve the crisis or which vehicle to move; it is simply a plain record describing what just happened.Once the ticket is ready, Hannah hands it to Tyler, who acts as Dispatch. Tyler is the dedicated runner and communication channel of the headquarters. He does not open the ticket to analyze it, nor does he have the authority to alter any records on his own. His only responsibility is to take that Action and deliver it straight into the main control room to trigger an official update.Inside the control room sits Chief Christin, the Reducer. Christin is the calm, rule-bound decision-maker who controls how the city’s status evolves. When Tyler drops the"NEED_AMBULANCE"ticket on her desk, Christin looks at two things: the current emergency records and the new ticket in front of her. Following strict departmental protocol, she does not scribble over old paperwork. Instead, she writes out a brand-new status sheet that preserves all existing city data while assigning Ambulance #4 to 5th Avenue. She then hands this updated sheet directly to the Master Command Board, which is the Store—the single source of truth holding the complete, up-to-date state of every emergency across the city.Across the control room stands Claire, the Selector. While the Master Command Board tracks hundreds of details—from fire trucks and police patrols to weather alerts—Hannah’s front-desk screen only cares about active ambulance dispatches. Claire keeps a sharp eye on the Store, and the moment Chief Christin updates the board, Claire extracts only that single slice of ambulance data, ignoring everything else.Claire immediately sends that specific ambulance update straight back to Hannah’s monitor. Hannah’s screen refreshes automatically, flashing the live status: "Ambulance #4 Dispatched to 5th Avenue." Through this smooth, one-way loop—from Hannah’s Action, carried by Tyler’s Dispatch, calculated by Chief Christin’s Reducer, saved in the Store, and filtered by Claire’s Selector—the entire emergency center stays synchronized without a single lost record.
Put Your Thought or Query Here