Redux Toolkit & RTK Query interview questions
This chapter tests modern Redux, not legacy boilerplate-first Redux.
Official Redux guidance recommends Redux Toolkit for Redux logic today. RTK Query is the optional data-fetching and caching layer included with Redux Toolkit.
Use this answer shape when useful:
problem
β
Redux mental model
β
API/pattern
β
trade-off
β
production implication
Fundamentalsβ
1. What problem does Redux solve?β
Strong answer: Redux provides a predictable external state container for shared application state. Updates happen through dispatched actions, reducers calculate the next state, and subscribed consumers select the state they need. Its real value appears when coordination, traceability, tooling, middleware, and cross-feature ownership matter.
Follow-up: When is local React state better?
Watch for: βRedux is where all React state should live.β
2. Why is Redux Toolkit the recommended way to write Redux today?β
Strong answer: Redux Toolkit packages the recommended Redux patterns into APIs such as configureStore and createSlice, reduces boilerplate, uses sensible defaults, integrates Immer for reducer updates, supports TypeScript well, and includes tools such as RTK Query.
Follow-up: Is Redux Toolkit a different state-management model from Redux?
Watch for: Treating RTK as an unrelated replacement for Redux.
3. What does configureStore give you?β
Strong answer: A correctly configured Redux store with reducer composition, thunk middleware, development checks, and DevTools integration by default, while still allowing custom middleware and configuration.
Follow-up: When would you customize middleware?
Watch for: Recreating old createStore setup for new code without a reason.
4. What does createSlice do?β
Strong answer: It groups a slice name, initial state, reducers, generated action creators, and generated action types into one feature-oriented definition. Its reducers may use mutating-looking syntax because Immer produces immutable updates underneath.
Follow-up: Does state.value++ literally mutate the Redux store state in place?
Watch for: Saying Immer means immutability no longer matters.
5. What is an action in Redux?β
Strong answer: A plain description of something that happened, typically represented by a plain object with a type and optional payload. In modern RTK, action creators are commonly generated by slices.
Follow-up: Why keep actions descriptive rather than UI-specific?
6. What is a reducer?β
Strong answer: A pure state-transition function that derives the next state from the current state and an action. It should not perform arbitrary side effects.
Follow-up: Where should async work go instead?
Watch for: Calling APIs inside reducers.
7. What does the Redux store actually contain?β
Strong answer: The application state tree managed by the configured reducers, plus the store machinery for dispatching, subscribing, and reading state. It should contain state that benefits from Redux ownership, not every transient value in the UI.
8. What is the role of React-Redux Provider?β
Strong answer: It places the Redux store instance into React context so React-Redux hooks can access that store. Context is distributing the store object; Redux itself owns the external state.
Follow-up: Why is this different from storing the entire application state directly in Context?
9. What do useSelector and useDispatch do?β
Strong answer: useDispatch gives a dispatch function for sending actions. useSelector subscribes the component to the selected result from the store and re-renders when that selected result changes according to the selector/equality behavior.
Follow-up: Why should selectors be narrow?
10. Why can this selector cause avoidable renders?β
useSelector((state) => ({
name: state.user.name,
role: state.user.role,
}))
Strong answer: It creates a new object every time the selector runs. Even if the fields did not change, the result identity can change. Use separate selectors, memoized selectors, or an appropriate equality strategy when object aggregation is needed.
Watch for: βDestructuring automatically prevents renders.β
Selectors and derived stateβ
11. What belongs in a selector?β
Strong answer: Reading or deriving state for consumers. Selectors centralize lookup rules and can hide state shape from components.
12. When should you use memoized selectors?β
Strong answer: When derived computation is expensive or result identity matters for downstream consumers. Do not memoize every simple property lookup.
13. What is normalized state and why use it?β
Strong answer: Entities are stored by ID with relationships represented separately, reducing duplication and making updates/lookups more predictable. It can be useful for large collections and relational client state.
Follow-up: When is normalization unnecessary?
14. What does createEntityAdapter help with?β
Strong answer: Common normalized-entity operations and selectors for collections managed in Redux. It reduces repetitive CRUD state logic.
Async logicβ
15. Should every API request use createAsyncThunk?β
Strong answer: No. createAsyncThunk is useful for generic async workflows that belong in Redux logic, but server-data fetching/caching is often better modeled with RTK Query when the application already uses Redux.
Watch for: Treating thunks as the default server cache.
16. What problem does createAsyncThunk solve?β
Strong answer: It standardizes an async operationβs pending/fulfilled/rejected action lifecycle and integrates that lifecycle into reducers.
17. When would listener middleware be preferable to a thunk?β
Strong answer: When logic should react to actions or state changes across features, such as orchestration, workflows, debouncing, or reactive side effects that should not live inside a component.
18. Why should reducers remain side-effect free?β
Strong answer: Redux relies on predictable state transitions. Side effects make reducers non-deterministic and undermine replay/debugging/testability.
RTK Queryβ
19. What is RTK Query?β
Strong answer: A data-fetching and caching layer included with Redux Toolkit. It models remote/server state, generates query/mutation logic, manages cache lifetime, and can generate React hooks for endpoints.
Follow-up: Is RTK Query just a helper around createAsyncThunk that you use exactly the same way?
20. Why is server data a different concern from ordinary Redux client state?β
Strong answer: Remote data has freshness, cache lifetime, deduplication, refetching, invalidation, loading/error states, mutation reconciliation, and server authority. Those concerns are different from local client-owned state transitions.
21. What does createApi define?β
Strong answer: An API service containing endpoint definitions, cache behavior, generated reducer/middleware integration, and optionally generated React hooks.
22. What does fetchBaseQuery do?β
Strong answer: It is a lightweight wrapper around fetch intended as a convenient default baseQuery for common HTTP APIs.
23. Query vs mutation in RTK Query?β
Strong answer: Queries retrieve and cache data. Mutations create/update/delete data or perform server side effects and may trigger cache updates or invalidation.
24. What are RTK Query tags for?β
Strong answer: They declare relationships between cached query results and mutations so mutations can invalidate affected cache entries and cause appropriate refetching.
25. When would you update cache directly instead of invalidating?β
Strong answer: When the mutation response already contains the authoritative updated data and a direct cache update avoids an unnecessary refetch. Invalidation is often simpler; direct updates require more careful consistency logic.
26. What does βone API slice per base URLβ mean as a rule of thumb?β
Strong answer: RTK Query generally benefits from grouping related endpoints into a shared API service instead of creating many disconnected API slices, because tag invalidation and middleware/cache behavior work best within the same service boundary.
27. How does RTK Query differ from TanStack Query?β
Strong answer: Both solve server-state fetching/caching. RTK Query is integrated into Redux Toolkit and stores cache state in Redux infrastructure; TanStack Query is framework-focused server-state infrastructure that does not require Redux. Choice depends on architecture, existing dependencies, team conventions, and feature needsβnot raw capability alone.
TypeScriptβ
28. How should Redux hooks be typed in a TypeScript application?β
Strong answer: Derive RootState and AppDispatch from the actual configured store, then expose typed wrapper hooks so components do not repeatedly specify types.
29. Why derive types from the store rather than hand-writing them?β
Strong answer: It prevents drift between runtime configuration and TypeScript declarations.
30. What is a good type boundary for Redux actions?β
Strong answer: Let createSlice infer generated actions where possible and explicitly type payloads/domain values where inference needs help. Avoid manually maintaining giant action unions for modern RTK code.
Performanceβ
31. What usually causes Redux-related render problems?β
Strong answer: Overly broad selectors, unstable selector results, storing state too globally, dispatching high-frequency updates through a broad subscription graph, or doing expensive derivation without measurement.
32. Does Redux mean the whole app re-renders on every dispatch?β
Strong answer: No. Store subscribers are notified, but React-Redux selectors determine whether individual components need to re-render based on their selected result.
33. Would you put every keystroke from a local text input into Redux?β
Strong answer: Usually not. Keep transient local state local unless another part of the application genuinely needs to coordinate with it.
Testing and production architectureβ
34. How should Redux logic be tested?β
Strong answer: Reducers/selectors can be tested as pure logic. Feature behavior should also be tested through the UI with a real test store where practical. Avoid tests that only assert internal dispatch sequences unless the sequence itself is the contract.
35. How would you structure Redux in a large application?β
Strong answer: Prefer feature ownership: slices, selectors, API endpoints, and domain logic live near the feature or bounded context that owns them. Keep shared infrastructure small, define state ownership clearly, and avoid a single global folder that every team edits.
36. What data should never be persisted blindly from a Redux store?β
Strong answer: Secrets, credentials, tokens or sensitive server responses that do not belong in browser storage. Persistence is a security and lifecycle decision, not a convenience checkbox.
37. How would you migrate legacy Redux to modern RTK?β
Strong answer: Start by replacing store setup with configureStore, migrate reducers incrementally to createSlice, replace hand-written async patterns where appropriate, and consider RTK Query for server-data workflows. Keep adapters so ownership does not exist in two systems indefinitely.
38. Redux Toolkit vs Zustand: how do you choose?β
Strong answer: Redux Toolkit is stronger when explicit events, reducer structure, middleware, DevTools traces, predictable conventions, and large-team coordination are key. Zustand is attractive when a lightweight external store with selector subscriptions is enough. Complexity of the problem, not library popularity, should decide.
39. Redux Toolkit vs Context: how do you choose?β
Strong answer: Context is excellent for subtree-scoped values and low-to-moderate frequency shared React-owned state. Redux adds an external store, selector subscriptions, middleware, event history, tooling, and stronger large-scale conventions.
40. Senior scenario: a team stores API cache, form fields, modals, authentication metadata, and every input in one Redux slice. What do you change first?β
Strong answer: Classify ownership. Server cache moves to RTK Query or another server-state cache, complex forms belong in form state, local UI returns to components, authentication state is separated from authorization, and remaining genuinely shared client state is split by domain. The goal is not fewer Redux filesβit is one source of truth per concern.
Rapid-fire checksβ
configureStoreor legacycreateStorefor new code?configureStore.- Reducers perform network requests? No.
createSlicegenerates action creators? Yes.- RTK Query is optional? Yes.
- Query or mutation for changing server data? Mutation.
- Does
useSelectorautomatically memoize arbitrary object creation? No. - Should server cache and form draft usually share one Redux slice? No.
- Can Redux and Context coexist? Yes.
- Can Redux and TanStack Query coexist? Yes, if ownership is clear.
- Is Redux DevTools a reason to put all application state in Redux? No.