75 State Management interview questions with answers
75 State Management interview questions with detailed answers, sorted from basic to advanced. Free to practice, with progress saved automatically.
All State Management interview questions
What is Redux Toolkit (RTK)? Why use RTK instead of plain Redux?
How does createSlice work in RTK?
What is createAsyncThunk used for? What are its lifecycle states?
What is a selector in Redux? Why should you use createSelector?
What is RTK Query? What are its advantages over manual data fetching?
How do you define an API with createApi in RTK Query?
What is Redux middleware? Give examples of common middleware.
How does Redux DevTools work? What is time-travel debugging?
How do the useSelector and useDispatch hooks work in React-Redux?
When should you use Redux and when is it unnecessary?
What is Zustand? How does it compare to Redux in terms of complexity?
How do you create a store with Zustand?
How do you define actions in a Zustand store?
How does Zustand differ from Redux architecturally?
How do you prevent unnecessary re-renders in Zustand?
What is Zustand middleware? Give an example of the devtools middleware.
How does the persist middleware in Zustand work?
How do you split a Zustand store into multiple slices?
How do you use Zustand with TypeScript for type safety?
When should you choose Zustand over Redux Toolkit?
What is React Query (TanStack Query)? What is its main purpose?
How does the useQuery hook work? What are its basic parameters?
What is the useMutation hook used for? How do you handle optimistic updates?
How does cache invalidation work in React Query?
What are staleTime and gcTime (cacheTime) in React Query? What is the difference?
Why is React Query considered a 'server state' solution rather than 'global state'?
How do you configure React Query with QueryClient and QueryClientProvider?
What is refetchOnWindowFocus in React Query? When should you disable it?
How does prefetching work in React Query?
What are infinite queries in React Query? How do you use them for pagination?
What are dependent queries in React Query?
How do you handle errors in React Query?
How should QueryKeys be designed in React Query?
How do you implement optimistic updates in React Query?
How do you combine React Query with Next.js Server Components?
What is Jotai? How does it compare to Recoil?
How do you create and use atoms in Jotai?
How do async atoms work in Jotai?
Compare bundle size and performance between Jotai and Zustand.
What is a Jotai Provider? When do you need to use it?
When should you use atomic state management (Jotai) instead of Redux/Zustand?
Compare popular state management libraries: Redux Toolkit, Zustand, Context API, Jotai. When should you use each?
How does Redux Toolkit's createSlice work?
What is QueryClientProvider and how is it configured in React Query?
What is the difference between isLoading and isFetching in React Query?
What is placeholder data and initial data in React Query and how do they differ?
What is the select option in useQuery and what are its use cases?
How do you run parallel queries in React Query?
How do you cancel a query in React Query?
What are Query Filters in React Query?
What is useSuspenseQuery and when should you use it?
What is persistQueryClient and when should you use it?
What are the mutation lifecycle callbacks in React Query?
What is keepPreviousData (placeholderData with previous data) in React Query?
What is React Query DevTools and how does it help development?
How does React Query handle race conditions?
What is the enabled option in useQuery and what are its use cases?
What are the key differences between React Query and SWR?
What is Redux? Why do we need to use it?
What are the three core principles of Redux?
What is an action in Redux? What is the structure of an action?
What is a reducer in Redux? How do you write a proper reducer?
What is the Store in Redux? What are its main methods?
How do you classify state in a real React app, and which tool fits each kind?
When does a React project not need a state-management library yet?
Can the Context API replace Redux/Zustand? What does it lack compared to a state manager?
Where should a list page keep its filters and pagination? Why put them in the URL?
A component using Zustand re-renders constantly (or loops) when selecting several fields. Why, and how do you fix it?
How do you read/write a Zustand store from outside React (interceptors, socket handlers)? And how do you reset it between tests?
Why does writing `state.value += 1` inside a Redux Toolkit `createSlice` not break immutability? What are the traps?
What is normalized state, and why avoid storing the API's nested arrays as-is in the store?
Should form state (values being typed) live in Redux/Zustand? Why or why not?
Persisting state to `localStorage` (cart, theme) across reloads — what is the SSR hydration trap and how do you handle it?
With Redux Toolkit already in the project, when should you still write `createAsyncThunk` versus moving to RTK Query? How do you cancel duplicate requests?
Why should you avoid creating a Zustand store at module level in Next.js? What is the correct pattern?