Skip to the page

State management and data fetching · senior

Redux Toolkit: slices, selectors, side effects and RTK Query

Redux Toolkit (2.x) is the standard way to write Redux: configureStore sets up devtools and safety checks, createSlice uses Immer so you can write "mutating" reducers, memoized selectors prevent re-renders, and side effects go in thunks, the listener middleware or RTK Query.

The notes

What you must know

  • configureStore adds Redux DevTools, the thunk middleware, and development checks for mutation and non-serializable values.
  • createSlice generates action creators and a reducer; Immer turns draft mutations into immutable updates.
  • useSelector re-renders when the selected value changes by reference; selectors that return new arrays or objects need createSelector (Reselect) memoization.
  • Middleware signature: store => next => action => { ...; return next(action) }.
  • Side effects: createAsyncThunk (pending/fulfilled/rejected actions plus an abort signal); the listener middleware (react to actions, cancelActiveListeners, delay) for orchestration; redux-saga (generators, takeLatest) still exists in older codebases but RTK recommends the listener middleware for most cases.
  • Server data belongs in RTK Query, not hand-written slices: endpoints, caching, tag invalidation, polling, optimistic updates via onQueryStarted.
  • createEntityAdapter normalises collections by id (ids array + entities map) so one update reaches every view.
  • Current line is 2.x (2.14 in late 2026) with a 3.0 roadmap announced; Redux core 5 and React-Redux 9 pair with it. (Version detail from release listings; verify before quoting.)

The red pen

Common traps: mistake → fix

  • Mistake: "Put async logic in reducers"

    Fix: reducers must be pure; use thunks or listeners.

  • Mistake: "Sagas for every fetch"

    Fix: heavy; use RTK Query.

  • Mistake: "Immer means Redux state is mutable"

    Fix: Immer produces new immutable objects.

Easy to hard

Questions interviewers ask, easy to hard

  1. What does Redux Toolkit add on top of plain Redux?
  2. Why can createSlice reducers "mutate"?
  3. Why do derived arrays break useSelector equality, and how does createSelector help?
  4. Thunk vs saga vs listener middleware: implement "cancel the previous search request" in each.
  5. When would you move fetching to RTK Query?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview