Loading

Quipoin Menu

Learn • Practice • Grow

react / Redux Actions and Reducers
interview

Q1. What is an action creator?
An action creator is a function that returns an action object. It helps encapsulate action creation logic. Example: const addTodo = (text) => ({ type: 'ADD_TODO', payload: text });

Q2. How do you define a reducer?
A reducer is a function that takes state and action, and returns new state. It typically uses a switch statement on action.type. Reducers must be pure and never mutate state.

Q3. What is the purpose of combineReducers?
combineReducers is a utility to combine multiple reducers into one root reducer. Each reducer manages a slice of the state. This helps organize code.

Q4. How do you handle asynchronous actions in Redux?
Use middleware like Redux Thunk or Redux Saga. Thunk allows action creators to return functions that dispatch actions asynchronously. Example: const fetchData = () => async (dispatch) => { ... }.

Q5. What is immutability in reducers?
Reducers must not mutate state. Instead, they return new objects. You can use spread operators or libraries like Immer to ensure immutability.