1. What are the advantages of using Redux with React?
It offers predictable state management, centralized store, and better debug-ability in large-scale apps.
const store = createStore(rootReducer);2. What is the role of the Provider component in Redux?
It wraps your main component to pass the Redux store to all nested components.
3. How does useSelector work?
It accesses values from the Redux state in functional components.
const data = useSelector(state => state.data);4. What is an action creator?
A function that returns an action object to trigger state change.
const updateValue = val => ({ type: ‘UPDATE’, payload: val });5. How do you handle async code in Redux?
Use middleware like redux-thunk to allow action creators to return functions.
dispatch(fetchDataAsync());6. What does a reducer do?
A reducer determines how the application’s state changes in response to an action.
function reducer(state = {}, action) { return state; }7. What are selectors in Redux?
Selectors extract and optionally transform data from the state.
const getActiveUsers = state => state.users.filter(u => u.active);8. How does Redux Toolkit simplify Redux?
It provides APIs like createSlice and configureStore to reduce boilerplate.
const slice = createSlice({ name: ‘auth’, initialState, reducers });9. What is immutability in Redux?
Redux state should never be mutated directly; always return a new state.
return […state, newItem];10. How does useDispatch help in Redux?
It lets you dispatch actions from functional components.
const dispatch = useDispatch(); dispatch({ type: ‘LOGIN’ });11. How can Redux DevTools help developers?
They allow inspection of state changes and time-travel debugging.
window.REDUX_DEVTOOLS_EXTENSION && window.REDUX_DEVTOOLS_EXTENSION()12. What does combineReducers do?
It merges multiple reducers into one root reducer.
const rootReducer = combineReducers({ auth, posts });13. How do you structure a large Redux project?
Organize code by features or domains: actions, reducers, types, and slices.
/src/store, /src/features/user/userSlice.js14. What is middleware in Redux?
Middleware intercepts dispatched actions for side effects like logging or async calls.
const logger = store => next => action => { console.log(action); return next(action); }15. What are thunks?
Thunks are functions returned by action creators for handling async logic.
const fetchUser = () => async dispatch => { const user = await getUser(); dispatch({ type: ‘SET_USER’, payload: user }); }16. How is Redux different from the Context API?
Context API is built-in and simpler, but Redux offers better scalability and middleware support.
useSelector vs useContext17. How do you test Redux logic?
Using Jest and mock store setup to simulate state and dispatches.
render(18. What are slices in Redux Toolkit?
They combine reducers and actions for a single feature into one unit.
const userSlice = createSlice({ name: ‘user’, reducers: { login: () => {} } });19. What is the difference between mapStateToProps and useSelector?
mapStateToProps is used with connect; useSelector is a hook used directly in function components.
connect(mapStateToProps)(Component) vs useSelector()20. What is the Redux store’s main responsibility?
It holds the application state and provides access and update mechanisms via dispatch and getState.
const store = configureStore({ reducer: rootReducer });
Search
Categories
Recent Posts
Top Git interview Questions for Experienced Developer
Speed-up tips and tricks for Windows 11
Top 15 Linux Commands used by Experienced Developer
Top SQL Interview Examples for Experienced Developer
Internal Working of Java HashMap
Recent Tags