Redux/Redux Toolkit Assignment – 3

Basic Questions

  1. Create a Redux Toolkit store and confirm that default middleware (Redux Thunk, serializability checks) is applied.
  2. Enable logging middleware using getDefaultMiddleware() in configureStore.
  3. Write a console log inside custom middleware that logs all dispatched actions.
  4. Create middleware that logs state before and after action is dispatched.
  5. Make middleware that only logs actions of type USER_LOGIN.
  6. Write middleware that blocks any action with type DELETE_USER.
  7. Update middleware to log only async thunk lifecycle actions (pending, fulfilled, rejected).
  8. Show how applying multiple middlewares works (log → validate → reducer).
  9. Inspect middleware array using DevTools to confirm middleware setup.
  10. Add error-catching middleware that logs errors in reducers/actions.
  11. Take an old Redux createStore() example and rewrite using configureStore().
  12. Convert a plain reducer function into a slice with createSlice().
  13. Replace manually written action creators with auto-generated ones from slice.
  14. Replace switch-case reducer logic with object methods in slice.
  15. Migrate a simple counter reducer written in plain Redux into RTK slice.
  16. Use combineReducers() in plain Redux and replace with configureStore() in RTK.
  17. Remove boilerplate action constants when moving to RTK slices.
  18. Write the same store with plain Redux and RTK side by side to compare.
  19. Switch a plain Redux dispatch({ type: “INCREMENT” }) into slice dispatch(counterActions.increment()).
  20. Refactor a Redux app to use Provider from react-redux with RTK.

Intermediate Questions

  1. Write a middleware that times the duration of each reducer execution.
  2. Create middleware that prevents duplicate API calls by checking a loading flag.
  3. Build middleware that saves state updates into localStorage.
  4. Modify middleware to rehydrate state from localStorage on app reload.
  5. Write middleware that delays an action by 2 seconds before passing it to reducers.
  6. Create middleware that converts all dispatched action types to uppercase in logs.
  7. Build a notification middleware that dispatches an extra action whenever ADD_TODO occurs.
  8. Combine custom logging middleware with Redux Toolkit’s built-in serializable check.
  9. Replace a manual logger setup with the redux-logger package as middleware.
  10. Create a middleware that cancels an action if the payload is invalid.
  11. Refactor a Redux todo reducer into todoSlice with addTodo/removeTodo.
  12. Replace a Redux async thunk written manually with RTK’s createAsyncThunk.
  13. Convert a Redux app with three reducers (auth, products, cart) into RTK with slices.
  14. Remove unnecessary boilerplate (mapDispatchToProps) after migrating to RTK hooks (useDispatch, useSelector).
  15. Replace bindActionCreators usage by directly importing auto-generated slice actions.
  16. Migrate a plain Redux middleware setup to middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(myMiddleware).
  17. Refactor a project to remove action constants and use slice-generated ones.
  18. Show how RTK reduces lines of code in action + reducer compared to plain Redux.
  19. Update a connected component (connect(mapStateToProps)) to use hooks after RTK migration.
  20. Document differences in debugging experience after migrating from Redux → RTK.

Advanced Questions

  1. Create a middleware that caches API responses: On duplicate request, return cached data instead of fetching.
  2. Write middleware that automatically dispatches a LOGOUT action if a token expires (timeout).
  3. Build middleware that tracks user actions and saves them to analytics (console log or fake API call).
  4. Implement middleware that debounces an action (SEARCH_QUERY) to prevent excessive dispatches.
  5. Create chained middleware workflow: log request → async API → cache response → error handler.
  6. Fully migrate a Redux authentication app from old reducers + actions → RTK authSlice + createAsyncThunk.
  7. Refactor a large Redux shopping cart app (with multiple reducers) into slices with configureStore.
  8. Rewrite API fetching logic in a Redux news app from manual thunks → RTK createAsyncThunk.
  9. Migrate a dashboard app using plain Redux DevTools configuration to RTK DevTools integration.
  10. Document and refactor a legacy Redux project into RTK, focusing on removing boilerplate while keeping functionality same.