Skip to content
IT glossary
FrontendUpdated December 3, 2026

Redux

Redux is a JavaScript library for managing shared application state. Code reports what happened, and a set of rules determines how the stored data changes.

What problem does Redux solve?

On a travel site, a filter panel, a results list, and a map may all need to agree on the price range and selected dates. If each view keeps its own copy, they can get out of sync. Redux lets them read from the same store and gives the app one place to define how those values change. It works with or without React; React Redux is the separate library that connects a Redux store to React components.

Follow an update

  1. The user picks a new price limit. The filter panel calls dispatch with an action, an object that identifies what happened with a type and often carries extra data in a payload.
  2. The store passes its current state and the action to the root reducer. The reducer returns the next state. It can return the existing state when the action does not change anything.
  3. The store saves that result and notifies its subscribers. A selector reads or derives a value from the state. In React Redux, useSelector checks the selected result so an unrelated update does not by itself trigger a render of that component.

The basic update for a plain action is synchronous. Middleware can add behavior around dispatch, including support for thunks: functions that run logic such as an API call and dispatch actions when it starts or finishes. The reducer itself stays pure: given the same state and action, it should produce the same result without performing side effects.

A small Redux Toolkit example

Redux Toolkit is the recommended way to write Redux code. Here createSlice generates both the reducer and an action creator, so there is no need to write the action type separately.

import { configureStore, createSlice } from '@reduxjs/toolkit';

const filters = createSlice({
  name: 'filters',
  initialState: { maxPrice: 500 },
  reducers: {
    priceLimitSet(state, action) {
      state.maxPrice = action.payload;
    },
  },
});

const store = configureStore({ reducer: { filters: filters.reducer } });
store.dispatch(filters.actions.priceLimitSet(300));
console.log(store.getState().filters.maxPrice); // 300

The assignment is not a mutation of the previous state. Redux Toolkit uses Immer to give the reducer a draft and produce an immutable update. That shortcut does not apply to objects read directly from the store.

When to use it, and what interviews test

Redux is useful when several features read and update the same data and seeing which actions caused which changes helps with debugging. A dropdown's open state can usually stay in the component that owns it. Likewise, you do not need to write reducers by hand for every API response: RTK Query can manage fetching and caching server data.

In an interview, be ready to trace an action to the UI and explain why reference identity matters. One common mistake is a selector that calls filter() on every run and returns a fresh array even when its inputs have not changed. By default, useSelector compares results with strict equality. A memoized selector can reuse the previous array when its inputs are unchanged.