🌍 ReactJS · subject

ReactJS State Management with Redux Syllabus

The State Management with Redux syllabus for ReactJS in full: 4 chapters and 12 topics, every one listed below, plus 51 State Management with Redux flashcards with answers.

4Chapters
12Topics
51Flashcards

State Management with Redux syllabus: all 4 chapters

Expand any chapter to see its topics and sub-topics.

  1. Introduction to Redux

    3 topics
    • What is Redux?
    • Core Principles
    • Redux vs Context API
  2. Setting Up Redux

    3 topics
    • Installing Redux and React-Redux
    • Creating a Store
    • Connecting Redux to React
  3. Redux Actions and Reducers

    3 topics
    • Defining Actions
    • Creating Reducers
    • Combining Reducers
  4. Redux Middleware

    3 topics
    • What is Middleware?
    • Using Redux Thunk
    • Using Redux Saga

ReactJS State Management with Redux flashcards — 51 questions with answers

  1. What is Redux?

    Redux is a predictable state-management library for JavaScript applications. It stores the entire application state in a single centralized store (a JavaScript object tree) and lets you update that state in a predictable way using actions and reducers. It is UI-agnostic but most commonly paired with React.

  2. What problem does Redux primarily solve in large applications?

    It solves the problem of managing shared/global state across many components. Instead of passing props down through many levels ('prop drilling') or scattering state across components, Redux centralizes state so any component can read or update it predictably.

  3. What are the three core principles of Redux?

    1) Single source of truth - the whole state lives in one store. 2) State is read-only - the only way to change state is to dispatch an action. 3) Changes are made with pure functions - reducers are pure functions that take the previous state and an action and return the next state.

  4. What does the Redux principle 'Single source of truth' mean?

    The entire state of the application is stored in one object tree inside a single store. This makes it easier to debug, inspect, persist, and share state across the app since there is only one authoritative source.

  5. What does the Redux principle 'State is read-only' mean?

    You can never mutate the state directly. The only way to trigger a state change is by dispatching an action - a plain object describing what happened. This ensures all changes are centralized and happen one at a time in a strict order.

  6. What does the Redux principle 'Changes are made with pure functions' mean?

    Reducers, which specify how state transforms in response to actions, must be pure functions: given the same inputs (state and action) they always return the same output and produce no side effects. They must return a new state object rather than mutating the existing one.

  7. What is a pure function, and why must reducers be pure?

    A pure function always returns the same output for the same input and has no side effects (no API calls, no mutations, no randomness). Reducers must be pure so state changes are predictable, testable, time-travel debuggable, and so React can reliably detect changes via reference equality.

  8. What are the four main building blocks of the Redux data flow?

    Store (holds state), Actions (plain objects describing what happened), Reducers (pure functions computing the next state), and Dispatch (the method used to send actions to the store).

  9. Describe the one-way (unidirectional) data flow in Redux.

    1) The UI dispatches an action. 2) The store runs the root reducer with the current state and the action. 3) The reducer returns a new state. 4) The store saves the new state and notifies subscribers. 5) The UI re-renders based on the new state. Data always flows in one direction.

  10. Compare Redux and the Context API: what is Context API primarily designed for?

    The Context API is a built-in React feature designed to avoid prop drilling by sharing values (like theme, locale, or current user) across the component tree. It is a dependency-injection/data-passing mechanism, not a full state-management system.

  11. What are the key differences between Redux and the Context API?

    Context is built into React and best for low-frequency, simple shared data; it has no built-in tooling. Redux is a dedicated library with a single store, strict update patterns, middleware, DevTools with time-travel, and better performance optimization for large, frequently-updated global state.

  12. When should you prefer the Context API over Redux?

    Prefer Context for small apps or for rarely-changing global values (theme, authenticated user, language) where you don't need middleware, DevTools, or complex update logic, and where re-render performance is not a concern.

  13. Why can the Context API cause performance issues that Redux avoids?

    When a Context value changes, every component consuming that context re-renders, even if it only uses part of the value. Redux with react-redux uses selectors and subscriptions so only components whose selected slice of state changed re-render.

  14. What two packages do you install to use Redux with React, and what is the modern recommended package?

    Classically you install 'redux' and 'react-redux'. The modern recommended approach is to install '@reduxjs/toolkit' (Redux Toolkit) together with 'react-redux'. Redux Toolkit includes the core Redux library plus utilities.

  15. What npm command installs Redux and React-Redux the classic way?

    npm install redux react-redux (or with yarn: yarn add redux react-redux). The modern recommendation is: npm install @reduxjs/toolkit react-redux.

  16. What is the role of the 'react-redux' package (as opposed to 'redux')?

    'redux' is the framework-agnostic core (store, reducers, dispatch). 'react-redux' is the official React binding layer that connects the store to React components via the <Provider> component and hooks like useSelector and useDispatch.

  17. What is a Redux store and what are its main responsibilities?

    The store is the object that holds the application state tree. Its responsibilities: hold state via getState(), allow updates via dispatch(action), register listeners via subscribe(listener), and handle unregistering of listeners. There is exactly one store per Redux app.

  18. How do you create a store with classic Redux?

    Import createStore from redux and pass it the root reducer: const store = createStore(rootReducer). You can optionally pass a preloaded initial state and enhancers/middleware. (Note: createStore is now deprecated in favor of configureStore.)

  19. How do you create a store using Redux Toolkit, and why is it preferred?

    Use configureStore from @reduxjs/toolkit: const store = configureStore({ reducer: rootReducer }). It is preferred because it automatically combines reducers, adds redux-thunk, enables Redux DevTools, and includes checks for immutability and serializability out of the box.

  20. What are the four core methods of a Redux store?

    getState() - returns the current state; dispatch(action) - sends an action to change state; subscribe(listener) - registers a callback run on every state change and returns an unsubscribe function; replaceReducer(nextReducer) - swaps the current reducer (used for code splitting / hot reloading).

Show the other 31 State Management with Redux flashcards
  1. How do you connect a Redux store to a React application?

    Wrap the root of your component tree in the <Provider> component from react-redux and pass the store as a prop: <Provider store={store}><App /></Provider>. This makes the store available to all nested components via context.

  2. What does the react-redux <Provider> component do?

    <Provider> uses React context to make the Redux store accessible to every component in the wrapped tree, so hooks like useSelector and useDispatch (and the legacy connect) can access the store without manually passing it down as props.

  3. What is the useSelector hook and how is it used?

    useSelector is a react-redux hook that lets a component read a value from the Redux store state. You pass it a selector function: const count = useSelector(state => state.counter.value). The component re-renders whenever the selected value changes (compared by reference equality by default).

  4. What is the useDispatch hook and how is it used?

    useDispatch is a react-redux hook that returns a reference to the store's dispatch function. You use it to dispatch actions: const dispatch = useDispatch(); dispatch(increment()). It replaces the need for mapDispatchToProps in function components.

  5. What is the connect() function in react-redux?

    connect() is the classic higher-order component (HOC) API that links a React component to the Redux store. It takes mapStateToProps and mapDispatchToProps and injects state slices and dispatch-bound action creators as props. In modern code the hooks (useSelector/useDispatch) are preferred.

  6. What are mapStateToProps and mapDispatchToProps in connect()?

    mapStateToProps(state) selects pieces of store state and returns them as props to the component. mapDispatchToProps(dispatch) creates functions that dispatch actions and passes them as props, letting the component trigger state changes without directly touching dispatch.

  7. What is an action in Redux?

    An action is a plain JavaScript object that describes an event or intention to change state. It must have a 'type' property (a string identifier) and may carry additional data, conventionally in a 'payload' field. Example: { type: 'counter/increment', payload: 1 }.

  8. What is the required property of every Redux action, and what convention is used for it?

    Every action must have a 'type' property, typically a descriptive string. The convention is to use a 'domain/eventName' format (e.g., 'todos/todoAdded') so the type is readable and namespaced, aiding debugging and DevTools.

  9. What is an action creator?

    An action creator is a function that returns an action object. Instead of writing action objects by hand, you call the creator: function increment(amount) { return { type: 'counter/increment', payload: amount }; }. This centralizes action shape and reduces errors.

  10. What is the 'payload' convention in a Redux action?

    By the Flux Standard Action (FSA) convention, any data an action carries is placed in a 'payload' field, while error info goes in 'error' and extra info in 'meta'. This keeps action structure consistent: { type, payload, error, meta }.

  11. What is a reducer in Redux?

    A reducer is a pure function with the signature (state, action) => newState. It takes the current state and an action, and returns the next state. It decides how the state should change in response to each action type, typically using a switch statement on action.type.

  12. What is the function signature of a Redux reducer?

    (previousState, action) => nextState. It receives the current state and the dispatched action and must return the new state (or the unchanged state if the action does not apply). It must not mutate previousState.

  13. Why must a reducer return the initial state when given undefined state?

    When the store is first created, Redux calls each reducer with state = undefined to populate the initial state tree. Reducers use a default parameter (e.g., state = initialState) to return their initial value; otherwise the store state would be undefined.

  14. Show the typical structure of a reducer using a switch statement.

    function counter(state = { value: 0 }, action) { switch (action.type) { case 'increment': return { ...state, value: state.value + 1 }; case 'decrement': return { ...state, value: state.value - 1 }; default: return state; } }

  15. Why must a reducer return the current state in its 'default' case?

    Because every dispatched action is passed to every reducer. If a reducer does not handle a given action type, it must return the existing state unchanged in the default case; otherwise it would return undefined and wipe out that slice of state.

  16. How do reducers update state immutably instead of mutating it?

    They create and return a new object/array copy with the changes applied, commonly using the spread operator ({ ...state, field: newValue }) or array methods that return new arrays (map, filter, concat). They never assign directly to the existing state object.

  17. What is combineReducers and why is it used?

    combineReducers is a Redux helper that merges multiple slice reducers into a single root reducer. Each key in the object passed to it becomes a key in the state tree, managed by its corresponding reducer. It is used to split state-handling logic by domain.

  18. Show how combineReducers is used.

    import { combineReducers } from 'redux'; const rootReducer = combineReducers({ users: usersReducer, posts: postsReducer, cart: cartReducer }); The resulting state shape is { users: ..., posts: ..., cart: ... }, each managed independently.

  19. In combineReducers, what determines the shape of the state tree?

    The keys of the object passed to combineReducers determine the state tree shape. Each key becomes a top-level property of the state, and the reducer at that key manages only that slice, receiving only state[key] as its state argument.

  20. In combineReducers, what slice of state does each individual reducer receive?

    Each reducer receives only its own slice of the state (the value at its key), not the entire state tree. For example, the usersReducer at key 'users' only ever sees and returns state.users.

  21. What is middleware in Redux?

    Middleware is a function that sits between dispatching an action and the moment it reaches the reducer. It provides an extension point to intercept, inspect, delay, transform, or dispatch additional actions - commonly used for logging, crash reporting, and asynchronous side effects.

  22. What is the curried function signature of Redux middleware?

    store => next => action => { ... }. It receives the store (with getState/dispatch), returns a function taking 'next' (the next middleware's dispatch), which returns a function taking the 'action'. Middleware typically calls next(action) to pass the action along.

  23. How do you apply middleware to a Redux store in classic Redux?

    Use applyMiddleware as a store enhancer: import { createStore, applyMiddleware } from 'redux'; const store = createStore(rootReducer, applyMiddleware(thunk, logger)). Middleware runs in the order listed. In Redux Toolkit, configureStore adds middleware automatically.

  24. Why is middleware needed for asynchronous logic in Redux?

    Reducers must be pure and synchronous, so they cannot perform async work like API calls. Middleware (e.g., thunk or saga) intercepts actions before they reach reducers, letting you run async side effects and dispatch resulting actions when the async work completes.

  25. What is Redux Thunk?

    Redux Thunk is middleware that lets action creators return a function (a 'thunk') instead of a plain action object. That function receives dispatch and getState, allowing you to perform asynchronous logic (like API calls) and dispatch actions conditionally or after delays.

  26. What is a 'thunk' in the context of Redux Thunk?

    A thunk is a function that wraps an expression or logic to delay its execution. In Redux, it is a function returned by an action creator with the form (dispatch, getState) => { ... }, inside which you can run async code and dispatch real actions.

  27. Write a typical async action creator using Redux Thunk.

    function fetchUser(id) { return async (dispatch) => { dispatch({ type: 'user/loading' }); try { const res = await api.getUser(id); dispatch({ type: 'user/loaded', payload: res }); } catch (e) { dispatch({ type: 'user/error', error: e.message }); } }; }

  28. What is Redux Saga?

    Redux Saga is middleware for managing side effects (especially async data fetching and complex flows) using ES6 generator functions. Sagas 'watch' for dispatched actions and run worker generators that yield declarative 'effects' (like call, put, takeEvery) to orchestrate side effects.

  29. What JavaScript feature does Redux Saga rely on, and what are common saga effects?

    Redux Saga relies on ES6 generator functions (function*, yield). Common effects include call (invoke a function/promise), put (dispatch an action), take/takeEvery/takeLatest (listen for actions), select (read state), fork (non-blocking task), and all (run effects in parallel).

  30. Compare Redux Thunk and Redux Saga: when would you choose each?

    Thunk is simpler, uses functions/promises, and is ideal for straightforward async logic and small-to-medium apps. Saga uses generators, is more verbose but more powerful for complex asynchronous flows, cancellation, debouncing, and orchestrating many concurrent side effects; it is also easier to test declaratively.

  31. In Redux Saga, what is the difference between takeEvery and takeLatest?

    takeEvery starts a new worker saga on every matching dispatched action, allowing concurrent handlers. takeLatest starts a worker on each matching action but automatically cancels any previous still-running worker for that action type, keeping only the response to the most recent action (useful for search/autocomplete).

ReactJS State Management with Redux FAQ

What is in the ReactJS State Management with Redux syllabus?

ReactJS State Management with Redux is split into 4 chapters: Introduction to Redux, Setting Up Redux, Redux Actions and Reducers and Redux Middleware. Together they contain 12 topics.

How many chapters are in ReactJS State Management with Redux?

4 chapters, containing 12 topics. The largest chapter is Introduction to Redux, with 3 topics.

Are there flashcards for ReactJS State Management with Redux?

Yes — a 51-card State Management with Redux deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.