Skip to main content

Command Palette

Search for a command to run...

Redux in a Minute: How Actions Shape Your UI

Understand how actions, reducers, and the store collaborate to keep your interface in sync When I first built a complex UI, the app state was scattered across components. Props drilling, duplicated state and unpredictable updates made debugging a nightmare. One afternoon I missed a tiny prop update and the UI silently broke. That’s when I discovered Redux. It transformed how I reason about state — predictable, centralized, and easy to trace. This post walks through that mental model so you can use Redux confidently. 👉 UI → Action → Reducer → Store → UI updates

Updated
3 min read
Redux in a Minute: How Actions Shape Your UI
S
Passionate Full-Stack JavaScript Developer focused on building intuitive, scalable, and user-centric digital experiences using modern technologies.Specialized in the MERN stack (React, Node.js, and MongoDB) with practical experience architecting end-to-end web applications and seamlessly integrating intelligent AI features into modern platforms. I am highly comfortable handling both pixel-perfect frontend interfaces and robust backend logic.Driven by turning complex problems into elegant production-ready code. You can explore my full range of work, architecture patterns, and live deployments through my portfolio and GitHub links featured below.Outside the digital world, I recharge by exploring nature—especially during the monsoon season.

In Redux, we have a reducer function that takes an action and a state value. When an action comes from the UI, it can be sent to the reducer.

  • When you click, you trigger an action! This means something exciting is about to happen! The action zooms into the reducer, carrying the state value along for the ride. Inside the reducer, all the magic happens, deciding what needs to be done based on the action dispatched.

  • The reducer is where all the thrilling decisions about the state value are made!

  • Once the action is complete and the state value gets updated, it's stored in the store.

  • After the state gets updated based on the action, it’s saved in the store.

  • So, you might wonder how our view will change once the state and value are updated.

  • To update the view, the UI needs to keep an ear on your store.

  • This means your view subscribes to the store.

  • Subscribing means that as soon as there's a state update, the view or UI gets the memo and updates itself accordingly.

Walkthrough — Step by step

  1. User interacts with the UI (click, form submit, network response).

  2. The UI dispatches an action describing what happened.

  3. The action and current state are passed to a reducer.

  4. The reducer computes and returns the new state (immutable update).

  5. The store saves the updated state.

  6. Views subscribed to the store (or using selectors/hooks) detect the change and re-render.

This strict flow guarantees predictable updates and makes it easy to trace how a particular action changed state.

Key Learnings

  1. Single source of truth: The store contains the entire app state.

  2. Actions are plain objects: They describe "what happened" but don't change state themselves.

  3. Reducers are pure functions: Given the same inputs they always return the same output and do not mutate inputs.

  4. Immutable updates: Reducers return new state objects — never mutate existing state.

  5. UI subscribes to state: Views listen to the store (or use hooks) and update when relevant state changes

Diagram — Visual flow (ASCII)

[User Click] 
     |
     v
[Dispatch Action] ---> { action: { type, payload } }
     |
     v
[Store] --calls--> [Reducer(currentState, action)]
     |                      |
     |                      v
     |                [New State returned]
     |                      |
     v                      v
[Store Updates State] <-- subscribers notified
     |
     v
[UI re-renders with new s

Conclusion

Redux may look complex at first, but the idea is simple:

  • One store holds all data

  • Actions describe what happens

  • Reducers decide how data changes

  • UI automatically updates when state changes

Redux follows a fixed flow, which makes your app:

  • Predictable

  • Easy to debug

  • Scalable

That's it 😊