All questions
Showing of 84What are the three core principles of Redux?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Redux rests on three principles: a single source of truth, read-only state, and changes made with pure functions.
- Single source of truth. One store holds the global state of the whole app, in a single object tree.
- State is read-only. State can only be changed by dispatching actions. An action is a plain object that describes what happened.
- Changes are made with pure functions. Reducers are pure functions that specify how the state changes in response to actions.
The store applies actions one at a time in a strict order, so two state updates never interleave. And because actions are plain objects, they can be logged and replayed for debugging.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a Redux store?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A Redux store is the object that holds your app's complete state tree, and the only place where that state can change. A standard Redux app has a single store.
Its main methods are:
getState()returns the current state.dispatch(action)sends an action, which runs the reducer and saves the new state.subscribe(listener)registers a listener that runs after each dispatch, and returns a function that unregisters it.
The core createStore function still works but is deprecated. Modern code uses Redux Toolkit's configureStore, which also adds the thunk middleware and connects Redux DevTools.
import { configureStore } from '@reduxjs/toolkit';
const store = configureStore({ reducer });
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are actions in Redux?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Actions are plain JavaScript objects that describe something that happened in the app. Every action must have a type field, a string such as 'ADD_TODO'. Any extra data usually goes in a payload field.
Dispatching an action is the only way to change Redux state, and the reducer reads its type to decide what to do. Because actions are plain objects, Redux DevTools can log and replay them.
An action creator, like addTodoAction below, is a function that builds the action object for you.
// Action object
const addTodo = {
type: 'ADD_TODO',
payload: {
id: 1,
text: 'Learn Redux'
}
};
// Action creator function
const addTodoAction = (text) => ({
type: 'ADD_TODO',
payload: { id: Date.now(), text }
});
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are reducers in Redux?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A reducer is a pure function that takes the current state and an action, and returns the new state. It specifies how the application's state changes in response to each action.
A reducer follows three rules:
- It calculates the new state only from its
stateandactionarguments. - It never modifies the existing state. It returns an updated copy instead.
- It has no side effects, such as API calls, timers or random values.
For an action it doesn't handle, a reducer returns the existing state unchanged. That is the default case below.
const todosReducer = (state = [], action) => {
switch (action.type) {
case 'ADD_TODO':
return [...state, action.payload];
case 'REMOVE_TODO':
return state.filter(todo => todo.id !== action.payload.id);
default:
return state;
}
};
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between actions and action creators?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
An action is the plain object that describes what happened, and an action creator is a function that builds and returns that object. You dispatch the action. The action creator just saves you from writing the object by hand.
An action has a type property and usually a payload. An action creator takes arguments, such as the amount to add, and puts them into the payload. That keeps the action's shape in one place, so every caller sends the same structure.
An action creator can also prepare data before the action exists, like a generated ID or a timestamp. In Redux Toolkit you rarely write one yourself, because createSlice generates an action creator for every reducer you define.
// Action
const action = { type: 'INCREMENT', payload: 1 };
// Action creator
const increment = (value) => ({
type: 'INCREMENT',
payload: value
});
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you connect React components to the Redux store?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
You connect components with the React-Redux library, in three steps:
- Wrap the app once in the
Providercomponent, so every component below it can reach the store. - Read data with the
useSelectorhook. It runs your selector function and re-renders the component when the selected value changes. - Send actions with the
useDispatchhook, which returns the store'sdispatchfunction.
Select only the data a component needs, like state.todos, rather than the whole state object. A component that selects everything re-renders on every state change. The older connect function with mapStateToProps still works, but the hooks are the recommended default.
// App.js
import { Provider } from 'react-redux';
<Provider store={store}>
<App />
</Provider>
// Component
import { useSelector, useDispatch } from 'react-redux';
const todos = useSelector(state => state.todos);
const dispatch = useDispatch();
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the purpose of the Provider component in React-Redux?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The Provider component makes the Redux store available to every component nested inside it, without passing the store down as props. You render it once near the root of the app.
It works through React's context. Provider puts the store instance into context, and the useSelector, useDispatch and connect APIs read it from there. Context carries only the store, not the current state. So a state change does not re-render everything under Provider. Each component subscribes to the store and re-renders only when its selected data changes.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is dispatching in Redux?
Why should reducers be pure functions?
What is configureStore and what advantages does it provide?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
configureStore is Redux Toolkit's function for creating a store. It wraps the core createStore with good defaults, so one call replaces the manual store setup.
- Reducers combined. Pass an object of slice reducers, and it calls
combineReducersfor you. - Middleware included. It adds the thunk middleware. In development it also adds checks that catch accidental state mutations and non-serializable values.
- DevTools connected. It sets up the Redux DevTools Extension automatically.
Options such as middleware and devTools change these defaults. Since createStore is now deprecated, configureStore is the standard way to create a store.
const store = configureStore({
reducer: {
counter: counterSlice.reducer,
user: userSlice.reducer
}
});
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the concept of "slices" in Redux Toolkit
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A slice is the part of the Redux state that belongs to one feature, together with the reducer logic and actions for that feature. A todos slice, for example, owns state.todos and the actions that change it.
You create a slice with createSlice, giving it a name, an initial state and an object of reducer functions. From those it generates:
- the slice reducer, which you add to the store under the slice's key
- an action creator for each reducer, and an action type such as
'todos/todoAdded'
So you no longer write action type constants, action creators and switch statements by hand. Each feature's Redux logic lives in one slice file, which keeps a large app organized by feature.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is Redux and what problem does it solve?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Redux is a library that keeps an app's shared state in one central store, which changes only through dispatched actions and pure reducers. It is most often used with React, through React-Redux.
It solves the problem of shared state in a growing app. When many distant components read and update the same data, passing props through every layer gets messy. It also becomes hard to see what changed the state. With Redux, any component can read that data from the store.
Every change is an action, so changes are predictable and can be traced, which powers Redux DevTools. The cost is extra setup, so state used by only one component, like an input's value, usually stays local.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is unidirectional data flow in Redux?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Unidirectional data flow means data in a Redux app always moves around one loop, in the same direction. Components never change the state directly. They can only send actions into the loop.
- The UI renders from the current state in the store.
- An event, like a click, makes the app dispatch an action.
- The store runs the reducer with the current state and the action, and saves the new state it returns.
- The store notifies its subscribers, and components whose selected data changed re-render with the new state.
Because every change takes this one path, you can trace any state change back to the action that caused it. That makes bugs easier to find and the app easier to reason about.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Why is immutability important in Redux?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Redux and React-Redux detect changes by comparing references, so state must be updated immutably. You create new objects for whatever changed, instead of modifying the existing ones. If a reducer mutates state in place, the reference stays the same, and the change goes unnoticed.
- UI updates.
useSelectorcompares the old and new selected values with===. A mutated object looks unchanged, so the component doesn't re-render. - Fast change checks. Comparing references is cheap, so selectors can run after every action.
- Reliable history. Old state objects stay untouched, so Redux DevTools can show earlier states and time-travel debugging works.
Immutable updates copy only the changed path, not the whole tree. Redux Toolkit uses Immer, so you can write "mutating" code inside createSlice and still get an immutable update.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is Redux Toolkit (RTK) and why should you use it?
How do you combine multiple reducers in Redux?
What is the purpose of Redux DevTools?
What is Redux middleware and how does it work?
What is Redux Thunk and when would you use it?
What is the difference between mapStateToProps and useSelector?
How do you handle asynchronous actions in Redux?
What are selectors in Redux and why are they important?
What is the difference between Redux and Context API?
What is the difference between Redux and MobX?
How do you handle form state in Redux?
How do you prevent unnecessary re-renders in Redux?
How does createSlice work and what does it return?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
createSlice turns a slice name, an initial state and an object of reducer functions into a slice reducer plus an action creator for each reducer. It returns them in one object, which removes the hand-written action types and switch statements of classic Redux.
How it works:
- Each key in
reducersbecomes an action type prefixed with the slice name, such as'counter/increment'. - Each case reducer is wrapped in Immer, so it can "mutate"
stateand still produce an immutable update. extraReducersadds handlers for actions defined elsewhere, like thunk results, without generating new action creators.
The returned object holds:
reducer, the slice reducer to pass toconfigureStoreorcombineReducersactions, an action creator for each case reducer, usually exported by destructuringname, the slice namegetInitialState, a function that returns the initial statecaseReducers, the original reducer functionsselectors, for any selectors you define
const counterSlice = createSlice({
name: 'counter',
initialState: { value: 0 },
reducers: {
increment: (state) => {
state.value += 1; // Immer makes this safe
},
incrementByAmount: (state, action) => {
state.value += action.payload;
}
}
});
// Returns: { reducer, actions: { increment, incrementByAmount } }
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How does Immer integration work in Redux Toolkit?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
createSlice and createReducer run every case reducer inside Immer's produce. Your reducer receives a draft, a Proxy that wraps the current state, so you can write "mutating" code like state.todos.push(todo). Immer tracks each change to the draft and replays it as an immutable update, which creates a new state tree.
- Structural sharing. Immer copies only the objects along the path you changed. Unchanged parts keep their old references, so components reading them don't re-render.
- Mutate or return, not both. A reducer can change the draft or return a new value, but not both in one function. Assigning
state = newValuedoes nothing, because it only rebinds the local variable. - Frozen results. Immer freezes the state it produces, so an accidental mutation outside a reducer throws an error.
To log a draft readably, wrap it in current(state). The mutating style only works inside Immer, so the same code in a plain reducer would really mutate state. The draft keeps the state's TypeScript type, so typing works as usual.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are extraReducers and when would you use them?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
extraReducers lets a slice respond to actions it did not define in its own reducers field. Unlike reducers, it generates no action creators or action types. It only adds handlers for actions that already exist.
Use it for:
- the
pending,fulfilledandrejectedactions of acreateAsyncThunk - actions defined by another slice, like resetting state on logout
- RTK Query endpoint matchers
You write it with the builder callback. addCase handles one action type, addMatcher handles a range of actions, and addDefaultCase handles the rest. The old object notation was removed in Redux Toolkit 2.0, so the builder is the only form.
const userSlice = createSlice({
name: 'user',
initialState: { data: null, loading: false },
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchUser.pending, (state) => {
state.loading = true;
})
.addCase(fetchUser.fulfilled, (state, action) => {
state.data = action.payload;
state.loading = false;
});
}
});
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you handle complex state updates with nested objects in RTK?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
With Redux Toolkit you update nested data by assigning to it directly, like state.profile.address.city = action.payload. createSlice runs reducers through Immer, which turns those writes into an immutable update and copies only the objects on the changed path.
Common patterns:
- Replace a nested object by assigning a new value to its property, as
updateAddressdoes below. - Update one deep field by assigning to that field, as
updateCitydoes. - Update an item in an array by finding it first and then changing it, like
state.items.find(item => item.id === id).
Arrays also support push and index assignment directly on the draft.
Two rules prevent bugs. Either mutate the draft or return a new state, never both in one reducer. And never reassign state itself, because that only changes the local variable.
For data nested many levels deep, normalizing it by ID keeps reducers flat. You can still return a new state object when that logic reads more clearly.
const userSlice = createSlice({
name: 'user',
initialState: {
profile: {
name: '',
address: {
street: '',
city: ''
}
}
},
reducers: {
updateAddress: (state, action) => {
// Direct assignment works with Immer
state.profile.address = action.payload;
},
updateCity: (state, action) => {
state.profile.address.city = action.payload;
}
}
});
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the prepare callback in RTK reducers?
What is createAsyncThunk and how does it work?
How do you handle loading states with createAsyncThunk?
What are the options available in createAsyncThunk's thunkAPI parameter?
What is RTK Query and how does it differ from createAsyncThunk?
How do you define an API service with RTK Query?
How do you test Redux Toolkit slices and async thunks?
What are RTK Query hooks and how do they work?
How do you handle RTK Query conditional fetching?
How do you handle RTK Query error scenarios?
How do you implement pagination with RTK Query?
How do you handle file uploads with RTK Query?
How do you decide which state belongs in Redux and which stays local?
How do you type the Redux store and hooks in TypeScript?
Explain the concept of Redux state normalization and its benefits
What is the difference between Redux Saga and Redux Thunk?
How would you implement feature flags in Redux?
What are entity adapters and when should you use them?
How do you handle side effects and middleware with RTK?
How do you implement middleware for logging and debugging in RTK?
How do you implement custom RTK Query transformations?
How do you test RTK Query endpoints?
Explain Redux middleware composition and how it works internally
How would you implement undo/redo functionality in Redux?
What are the performance implications of Redux and how do you optimize them?
How do you implement middleware for API calls with caching?
How would you implement optimistic updates in Redux?
How would you implement a Redux store enhancer?
What are higher-order reducers and when would you use them?
How do you implement real-time updates with Redux?
How do you handle side effects testing in Redux applications?
How would you implement a time-travel debugging feature?
How do you implement custom equality checks for useSelector?
How would you implement state persistence with encryption?
How do you handle concurrent actions and race conditions in Redux?
What strategies would you use for Redux performance monitoring and debugging?
How would you implement a Redux-based state machine?
How do you implement Redux patterns with modern React Server Components?
What are modern Redux patterns for handling authentication and authorization?
How do you handle complex async workflows with Redux?
What are the best practices for Redux in large-scale applications?
How does caching work in RTK Query?
How do you handle optimistic updates with RTK Query?
How do you implement custom base queries in RTK Query?
How do you handle code splitting and lazy loading of Redux slices?
How do you implement RTK Query with authentication?
How do you implement RTK Query batch operations?
How do you implement RTK Query with WebSocket streaming?
How do you implement RTK Query cache invalidation strategies?
How do you handle optimistic updates with conflict resolution?
How do you implement RTK Query with TypeScript generics?
How do you implement custom cache selectors with RTK Query?
How do you implement comprehensive performance optimization for RTK Query?
When is Redux the wrong choice, and what would you use instead?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Redux in pictures.
A quick recap of Redux in 32 short animated pictures, one idea at a time. About 9 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 28 pictures come with Pro.
Redux cheatsheet
- Store, actions & reducers01
- Redux Toolkit & slices02
- Connect React components03
- Selectors & re-renders04
- Async logic & thunks05
- Middleware & DevTools06
- Fetch data with RTK Query07
- Update the RTK Query cache08
- Test Redux code09
- Design a Redux app10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 28 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in68 of 84 Redux answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.