Redux Interview Questions and Answers (Redux Toolkit)
Last updated 2026-11-19
Redux interviews today are Redux Toolkit interviews. The interviewer may start with the three principles and the data flow, but quickly moves to createSlice and Immer, async logic with createAsyncThunk, caching with RTK Query, selectors and re-render behaviour, and the question that matters most: when Redux is not the right tool.
This page covers both the core ideas and the modern API, including changes in Redux Toolkit 2 and Redux 5. It pairs with the React interview questions and React Hooks questions, because context, useReducer and server-state libraries are the alternatives you are expected to compare with.
| Versions | Redux 5, Redux Toolkit 2, React-Redux 9 |
|---|---|
| Core topics | Store, slices, Immer, thunks, RTK Query, selectors, alternatives |
| Questions here | 17 |
The core ideas in four lines
There is one store holding the whole state tree. The state is read-only, and the only way to change it is to dispatch an action describing what happened. Reducers are pure functions that take the previous state and an action and return the next state. React components read state with selectors and dispatch actions, so data flows in one direction and every change is traceable in DevTools.
What is different in modern Redux
- createSlice generates action creators and the reducer together, and uses Immer so you can write mutating-looking updates safely.
- configureStore sets up thunk middleware and development checks for mutation and non-serialisable values.
- RTK Query handles fetching, caching and invalidation, replacing most hand-written thunks for server data.
- Typed hooks via useSelector.withTypes and useDispatch.withTypes in React-Redux 9 remove repeated type annotations.
- Plain createStore is deprecated in favour of configureStore.
Redux Interview Questions and Answers (Redux Toolkit): questions with worked answers
1 What problem does Redux solve and what are its three principles?
easyRedux gives a predictable place for state shared by many parts of an app and makes changes traceable. The principles are a single source of truth in one store, state that is read-only except through dispatched actions, and changes made with pure reducers. Predictability comes from reducers having no side effects, so the same state and action always give the same result, which also makes time-travel debugging possible.
2 Describe the data flow in Redux.
easyA user event triggers dispatch of an action, an object with a type and optional payload. The store passes the action through middleware and then to the root reducer, which returns the next state. The store notifies subscribers, React-Redux re-runs selectors, and components whose selected values changed re-render. Side effects such as network calls happen in middleware or thunks, not in reducers.
3 What does createSlice do, and why can you write "mutating" code in it?
mediumcreateSlice takes a name, an initial state and reducer functions, and returns the reducer plus matching action creators with generated type strings. Reducers run on an Immer draft, so statements such as state.items.push(x) are recorded and converted to an immutable update. Either mutate the draft or return a new value, never both, and do not mutate state outside Immer-wrapped code.
javascriptimport { createSlice } from '@reduxjs/toolkit'; const cart = createSlice({ name: 'cart', initialState: { items: [] }, reducers: { added(state, action) { state.items.push(action.payload); }, removed(state, action) { state.items = state.items.filter(i => i.id !== action.payload); }, }, }); export const { added, removed } = cart.actions; export default cart.reducer;4 Set up a store and typed hooks in TypeScript.
mediumCall configureStore with a reducer map, derive RootState and AppDispatch types from the store, and create pre-typed hooks with withTypes so components do not repeat annotations. Wrap the app in Provider. configureStore adds thunk middleware and dev-only checks automatically.
typescriptexport const store = configureStore({ reducer: { cart: cartReducer, [api.reducerPath]: api.reducer }, middleware: (gdm) => gdm().concat(api.middleware) }); export type RootState = ReturnType<typeof store.getState>; export type AppDispatch = typeof store.dispatch; export const useAppSelector = useSelector.withTypes<RootState>(); export const useAppDispatch = useDispatch.withTypes<AppDispatch>();5 Why must reducers be pure and state immutable?
mediumRedux and React-Redux detect change by comparing references, so a reducer that mutates the existing object returns the same reference and subscribers see no change, and the UI does not update. Impure reducers, such as ones that call Math.random or Date.now, break replay and time-travel debugging and make tests unreliable. Immer in Redux Toolkit makes immutable updates easy, so you get both correctness and readable code.
6 How do you handle async logic with createAsyncThunk?
mediumcreateAsyncThunk takes an action type prefix and a payload creator, and dispatches pending, fulfilled and rejected actions automatically. Handle them in extraReducers to set status, data and error. It is fine for custom async flows, but for plain data fetching RTK Query removes most of this boilerplate.
javascriptexport const loadUser = createAsyncThunk('user/load', async (id, { rejectWithValue }) => { const res = await fetch('/api/users/' + id); if (!res.ok) return rejectWithValue(res.status); return res.json(); }); extraReducers: (b) => b .addCase(loadUser.pending, (s) => { s.status = 'loading'; }) .addCase(loadUser.fulfilled, (s, a) => { s.status = 'idle'; s.user = a.payload; }) .addCase(loadUser.rejected, (s) => { s.status = 'failed'; })7 What is RTK Query and what does it give you?
mediumRTK Query is a data fetching and caching tool in Redux Toolkit. You declare endpoints with createApi, and it generates hooks such as useGetPostsQuery that handle loading and error state, cache results by arguments, deduplicate identical requests, refetch on demand and keep cached data for a period after the last subscriber unmounts. Tags let mutations invalidate queries so lists refresh automatically.
javascriptexport const api = createApi({ reducerPath: 'api', baseQuery: fetchBaseQuery({ baseUrl: '/api' }), tagTypes: ['Post'], endpoints: (b) => ({ getPosts: b.query({ query: () => 'posts', providesTags: ['Post'] }), addPost: b.mutation({ query: (body) => ({ url: 'posts', method: 'POST', body }), invalidatesTags: ['Post'] }), }), }); export const { useGetPostsQuery, useAddPostMutation } = api;8 How do selectors work and why use createSelector?
mediumA selector is a function that reads data from state. useSelector re-runs it after each dispatch and re-renders the component if the returned value changes by strict equality. A selector that builds a new array or object each time therefore re-renders on every dispatch. createSelector memoises derived data and recomputes only when its input selectors return new values. Select the smallest slice a component needs.
javascriptconst selectItems = (s) => s.cart.items; export const selectTotal = createSelector([selectItems], (items) => items.reduce((sum, i) => sum + i.price * i.qty, 0));9 How do you normalise state and what is createEntityAdapter?
mediumStore collections as an object of entities by ID plus an ordered array of IDs, instead of nested arrays, so updating one item does not require searching or copying deep structures and each entity exists once. createEntityAdapter generates this shape with reducers such as addOne, upsertMany and removeOne, plus selectors like selectAll and selectById.
10 Redux, Context or Zustand: how do you choose?
mediumUse local state first, lifting only when needed. Context suits rarely changing values such as theme or the current user, but every consumer re-renders when the value changes, and it has no devtools or middleware. Redux Toolkit suits large apps with complex shared client state and many people editing it, thanks to enforced structure and tooling. Zustand offers a lighter store with less ceremony. For server data use RTK Query or TanStack Query rather than copying API responses into a store.
11 What is middleware in Redux?
mediumMiddleware sits between dispatch and the reducer, with the signature store => next => action. It can log, delay, transform or cancel actions and run side effects. Redux Thunk, included by default, lets you dispatch functions. Add your own through configureStore middleware callback and concat. The listener middleware in Redux Toolkit runs logic in response to actions without needing sagas.
javascriptconst logger = (store) => (next) => (action) => { console.log('dispatching', action.type); const result = next(action); console.log('next state', store.getState()); return result; };12 What does the serialisability check warn about?
mediumIn development, configureStore warns when actions or state contain values that cannot be serialised, such as Promises, class instances, Maps, Dates or functions. Redux DevTools, persistence and time travel depend on plain data. Store ISO date strings or timestamps, and keep non-serialisable objects outside the store. You can ignore specific actions or paths in the middleware options, for example for redux-persist actions, but do so deliberately.
13 How do you test reducers, thunks and connected components?
hardA reducer is a pure function, so test it by passing a state and an action and asserting on the result. Test selectors the same way. For thunks, create a store with the real reducer, dispatch the thunk against a mocked API and assert on final state. For components, render with a Provider around a store created by a helper, preloaded with state, and use React Testing Library to interact. Mock the network at the boundary using Mock Service Worker.
javascripttest('adds an item', () => { const next = cartReducer({ items: [] }, added({ id: 1, price: 10, qty: 1 })); expect(next.items).toHaveLength(1); });14 How do you avoid unnecessary re-renders with React-Redux?
hardSelect narrow values, not whole slices. Avoid returning new references from selectors: use createSelector or select primitives, or pass shallowEqual as the equality function when selecting a small object. Keep list items subscribed by ID so updating one item does not re-render the whole list, and wrap components in React.memo where props are stable. Check the React DevTools Profiler to confirm rather than guess.
15 What changed in Redux 5 and Redux Toolkit 2?
hardRedux 5 and RTK 2 moved to ESM and CJS dual packages and stricter TypeScript. Action types must be strings, createStore is formally deprecated, and the middleware option in configureStore must be a callback. RTK 2 added combineSlices for lazy-loaded reducers, the reducers callback syntax in createSlice for thunks inside slices, selectors defined in a slice, and a new listener and RTK Query improvements. Check the release notes for your exact version.
16 How do you handle optimistic updates?
hardApply the change to the store immediately, send the request, and roll back if it fails. With RTK Query, use onQueryStarted in a mutation: patch the cached result with updateQueryData, await queryFulfilled, and call the patch result undo method in a catch block. Invalidate or refetch afterwards to reconcile with the server, and show an error to the user on failure.
javascriptasync onQueryStarted(id, { dispatch, queryFulfilled }) { const patch = dispatch(api.util.updateQueryData('getPosts', undefined, (draft) => { const p = draft.find(x => x.id === id); if (p) p.liked = true; })); try { await queryFulfilled; } catch { patch.undo(); } }17 Thunks versus sagas versus listener middleware?
hardThunks are simple functions that can dispatch and read state, ideal for most async flows. Sagas use generator functions and effects for complex orchestration such as cancellation, debouncing and racing, with a steeper learning curve and more code. The listener middleware, built into Redux Toolkit, reacts to dispatched actions with async effects, covering most saga use cases at lower cost. Start with thunks and RTK Query, and add listeners where flows need reaction to actions.
18 When should you not use Redux?
hardWhen state is local to a component or a small tree, when the main need is server data caching, which TanStack Query or RTK Query solve better, or when the app is small and prop passing or Context is enough. Redux adds structure and indirection that pay off with many developers, complex cross-feature state and a need for tooling. Saying this clearly in an interview shows judgement rather than loyalty to a library.
Frequently asked questions
Is Redux still used in 2026?
Yes, widely in existing React apps, and Redux Toolkit is the recommended way to write it. New projects often combine it with RTK Query or choose lighter stores.
Should I learn plain Redux or Redux Toolkit?
Learn the core concepts so reducers and actions make sense, then use Redux Toolkit for all code. Interviews now expect RTK.
What is the difference between Redux and Context?
Context is a way to pass values down the tree. Redux is a state container with a defined update pattern, middleware and devtools, and finer-grained subscriptions through selectors.
Do I need Redux for a React job?
Many jobs use it, but not all. Know it well enough to read and write slices, and know the alternatives.
Related guides
More in Role-wise Interview Questions by Job and Tech Stack
- SDET Interview Questions and Answers
- Selenium Interview Questions and Answers
- Site Reliability Engineer (SRE) Interview Questions and Answers
- SOC Analyst Interview Questions and Answers
- Software Engineer Fresher Interview Questions and Answers
- Spring Boot Interview Questions and Answers (Spring Boot 3)
- Statistics for Data Science Interview Questions and Answers
- Tableau Interview Questions and Answers
- Terraform Interview Questions and Answers
- Web Performance Interview Questions and Answers
- Web Security and OWASP Interview Questions and Answers
- A/B Testing Interview Questions and Answers