Redux in React — React Technical Interview Questions & Answers

Redux in React

Redux in React

  • Redux is a predictable state container: one store, reducers are pure (state, action) => newState, you dispatch actions. UI subscribes. It’s Flux-shaped. You do not need Redux for a counter. You consider it when many distant screens share complex state (cart + checkout + admin) and you want time-travel/debug tools.
  • Modern Redux: Redux Toolkit (configureStore, createSlice). Don’t teach 2016 switch-statement boilerplate as ‘how we write Redux now’. Context+useReducer can cover smaller apps.
  • Redux in React — output: 1. dispatch({type:'inc'}) → reducer → new state → UI. Never mutate the old state.
  view click
      │ dispatch
      ▼
   reducer
      │ new state
      ▼
     store → UI

Technical Interview Tip: When Redux vs useState/Context. Mention RTK.

Code Examples for Redux in React

Example

// Redux idea
function reducer(state, action) {
  if (action.type === "inc") return { n: state.n + 1 };
  return state;
}
let state = { n: 0 };
state = reducer(state, { type: "inc" });
console.log(state.n);

Redux in React — output: 1. dispatch({type:'inc'}) → reducer → new state → UI. Never mutate the old state.

How to Explain Redux in React to an Interviewer

Must every React app use Redux?

No

What must a reducer not do?

Mutate state Fetch inside