Redux/Redux Toolkit Assignment – 1
Basic Questions
- Install Redux in a project using npm install redux.
- Create a Redux store using createStore().
- Define an initial state object with {count: 0}.
- Write a simple reducer function to increment the count.
- Create an action object { type: “INCREMENT” }.
- Dispatch the INCREMENT action and log the updated state.
- Write a reducer that handles both INCREMENT and DECREMENT actions.
- Access the current state using store.getState().
- Subscribe to the store and log whenever the state changes.
- Create a constant variable for action types instead of using strings directly.
- Write a reducer that returns a new state object instead of mutating the old one.
- Show the difference between mutating an array vs returning a new one with spread operator.
- Create a reducer managing a list of todos (ADD_TODO).
- Ensure a reducer never modifies the original state by using object spread {…state}.
- Write a reducer for toggling a boolean flag (TOGGLE_THEME).
- Add Redux DevTools extension enhancer when creating a store.
- Monitor actions using Redux DevTools and identify state changes.
- Use console.log() inside a reducer to debug action flow.
- Write a simple action creator function increment() that returns {type: “INCREMENT”}.
- Practice connecting Redux store in a basic React project with <Provider>.
Intermediate Questions
- Create a reducer for a shopping cart (ADD_ITEM, REMOVE_ITEM).
- Write a reducer managing authentication state (LOGIN, LOGOUT).
- Implement a reducer that handles a RESET state action.
- Combine multiple reducers using combineReducers().
- Add separate reducers for users and products and merge them.
- Dispatch multiple actions in sequence and observe the state changes.
- Create a counter app with Redux and display count in React component.
- Implement a reducer to manage notifications (add, remove).
- Write a reducer that updates a nested object property immutably.
- Replace an item in an array immutably using map().
- Remove an object from an array immutably using filter().
- Explain why returning state from a reducer without change is important.
- Record a session of dispatched actions in Redux DevTools timeline.
- Time-travel between dispatched actions using DevTools.
- Identify and fix an action type typo (“INCREMNT” vs “INCREMENT”) via debugging.
- Install and set up redux-thunk middleware with applyMiddleware().
- Write an async action creator that fetches data from an API and dispatches SUCCESS or FAILURE.
- Create loading, success, and error states for async data fetching with Redux.
- Monitor how async actions flow in Redux DevTools.
- Implement a middleware that logs every dispatched action to the console.
Advanced Questions
- Build a Redux-powered todo list app with add, toggle, and delete features.
- Implement a multi-reducer store (auth, products, cart) and manage shared state.
- Use redux-thunk to fetch product data from an API and update the store.
- Add error handling for failed API requests in Redux.
- Write custom middleware that checks if an action type is ASYNC and logs a warning.
- Use Redux DevTools to rewind actions and identify a state regression bug.
- Optimize a Redux reducer by splitting a large state tree into smaller reducers.
- Analyze performance impact of unnecessary re-renders caused by mutable state.
- Build a Redux-based Authentication Flow (login/logout + JWT simulation).
- Create a dashboard app where API data (users, posts) is fetched via thunks and displayed with different reducers.