← All topics

State Management Junior interview questions and answers

75 questions for a State Management (Junior) interview - with correct answers, explanations and links to the docs.

Take this quiz
  1. 1.What is "state" in a React component?
  2. 2.Why doesn't the counter on screen change?
  3. 3.When should you use the functional update setCount(c => c + 1) instead of setCount(count + 1)?
  4. 4.What's the right way to update one field of an object in state?
  5. 5.How do you remove an item with id from an array in state?
  6. 6.Why pass a function to useState(() => createInitialTodos())?
  7. 7.Should you store fullName in state if you already have firstName and lastName?
  8. 8.What is "local" (component) state and when is it enough?
  9. 9.What does useReducer return?
  10. 10.What must a reducer function be like?
  11. 11.When is useReducer usually a better choice than several useState calls?
  12. 12.What does a reducer usually return for an unknown action type?
  13. 13.Why name actions after what happened ('task_added') rather than what to do ('set_tasks')?
  14. 14.What is prop drilling?
  15. 15.What is "lifting state up"?
  16. 16.Which technique often solves prop drilling without Context?
  17. 17.Is passing props down 2–3 levels a problem by itself?
  18. 18.What problem does the Context API solve?
  19. 19.What are the steps to use Context?
  20. 20.What does useContext(ThemeContext) return if there's no provider above?
  21. 21.Which components re-render when a provider's value changes?
  22. 22.Which data is a good fit for Context?
  23. 23.Why wrap useContext in a custom hook like useAuth()?
  24. 24.Can a component use several contexts at once?
  25. 25.What is Redux Toolkit (RTK)?
  26. 26.What does createSlice generate?
  27. 27.Why can you "mutate" state inside createSlice reducers?
  28. 28.What does configureStore do?
  29. 29.How do you connect a Redux store to a React app?
  30. 30.What are useSelector and useDispatch for?
  31. 31.What is an action in Redux?
  32. 32.Where should a request to the server live in Redux Toolkit?
  33. 33.What is Zustand?
  34. 34.How do you read just one field from a Zustand store?
  35. 35.How do you update state in Zustand?
  36. 36.Does a Zustand store require a Provider component?
  37. 37.How do you save a Zustand store to localStorage?
  38. 38.How does server state differ from client (UI) state?
  39. 39.What is TanStack Query (React Query) for?
  40. 40.What are the two required parts of useQuery?
  41. 41.What's needed before calling useQuery in an app?
  42. 42.How do you send a POST request (create an item) with TanStack Query?
  43. 43.Why does TanStack Query refetch data when you return to the browser tab?
  44. 44.What is RTK Query?
  45. 45.What does createApi generate for an endpoint getPosts: builder.query(...)?
  46. 46.How does an RTK Query mutation make lists refetch after adding an item?
  47. 47.What does the name SWR stand for?
  48. 48.What are the arguments of useSWR(key, fetcher)?
  49. 49.What is a loader in React Router?
  50. 50.What is an action in React Router?
  51. 51.Does changing the argument of useState(initial) on later renders update the state?
  52. 52.When should two pieces of state be combined into one object?
  53. 53.Where should a Context provider be placed?
  54. 54.Which three principles describe classic Redux?
  55. 55.What do the Redux DevTools let you do?
  56. 56.Why define selector functions like selectCartTotal(state) instead of inline lookups everywhere?
  57. 57.Where does the argument go when you dispatch todoAdded("Buy milk") created by createSlice?
  58. 58.What does a Redux store object provide?
  59. 59.What is createAsyncThunk for?
  60. 60.How does a Zustand action read the current state?
  61. 61.Why can Zustand cause fewer re-renders than a single Context for the same state?
  62. 62.Which fields of a useQuery result do you usually render from?
  63. 63.How do you manually refetch a query, e.g. from a "Refresh" button?
  64. 64.What do the TanStack Query Devtools show?
  65. 65.Which hooks does RTK Query generate for getPosts (query) and addPost (mutation) endpoints?
  66. 66.How does isLoading differ from isValidating in SWR?
  67. 67.Why should an SWR fetcher throw on non-OK HTTP responses?
  68. 68.How do you read the :id part of the URL /users/:id in a React Router component?
  69. 69.How does a React Router loader know which item to load?
  70. 70.Where should a search box's query live so the page can be shared and survives reload?
  71. 71.A small app has a theme switch and a logged-in user. Which state tools are usually enough?
  72. 72.What is a "store" in state management libraries?
  73. 73.How can a component remember a setting in localStorage between visits?
  74. 74.What does a typical action object for useReducer look like?
  75. 75.What is the "atomic" state approach of libraries like Jotai?