Skip to content
UniCircle
MediumConceptualState management

Redux principles and data flow

Question REACT-RDX-001

What are the core principles of Redux? Describe the flow of an action through the store, reducer and UI, and say when Redux is worth adding to a project.

Show the explanation

Model answer. Redux is a library for predictable global state. Three principles:

  1. Single source of truth: the whole app's shared state lives in one store object.
  2. State is read-only: the only way to change it is to dispatch an action, a plain object describing what happened ({ type: 'cart/itemAdded', payload: item }).
  3. Changes are made by pure reducers: (state, action) => newState, without mutating the old state.

Data flow (one-way):

text
UI event → dispatch(action) → [middleware] → reducer(s) compute new state → store saves it
        → subscribed components whose selected data changed re-render

With Redux Toolkit (the recommended way today):

JavaScript
const cartSlice = createSlice({
  name: 'cart',
  initialState: { items: [] },
  reducers: { itemAdded(state, action) { state.items.push(action.payload); } },   // Immer makes this immutable
});
// in a component
const count = useSelector(s => s.cart.items.length);
const dispatch = useDispatch();
dispatch(cartSlice.actions.itemAdded(product));

Worth adding when much state is shared across distant parts of the app, updates are complex, or you want time-travel debugging and a strict pattern for a large team. For small apps, local state plus context is enough, and server data (fetching and caching) is usually better handled by a library like RTK Query or TanStack Query.

Original UniCircle question. Last reviewed 22 Oct 2026.