🌍 The Odin Project · subject

The Odin Project React Syllabus

The React syllabus for The Odin Project in full: 6 chapters and 24 topics, every one listed below, plus 49 React flashcards with answers.

6Chapters
24Topics
49Flashcards

React syllabus: all 6 chapters

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

  1. Getting Started With React

    7 topics
    • Introduction To React
    • Setting Up A React Environment
    • React Components
    • What Is JSX?
    • Passing Data Between Components
    • Rendering Techniques
    • Keys In React
  2. States And Effects

    5 topics
    • Introduction To State
    • More On State
    • How To Deal With Side Effects
    • Project: CV Application
    • Project: Memory Card
  3. Class Components

    2 topics
    • Class Based Components
    • Component Lifecycle Methods
  4. React Testing

    2 topics
    • Introduction To React Testing
    • Mocking Callbacks And Components
  5. The React Ecosystem

    5 topics
    • Type Checking With PropTypes
    • React Router
    • Fetching Data In React
    • Styling React Applications
    • Project: Shopping Cart
  6. More React Concepts

    3 topics
    • Managing State With The Context API
    • Reducing State
    • Refs And Memoization

The Odin Project React flashcards — 49 questions with answers

  1. What is React?

    A JavaScript library for building user interfaces out of reusable components. It uses a declarative approach: you describe what the UI should look like for a given state, and React updates the DOM to match.

  2. What is a React component?

    A reusable, self-contained piece of UI. In modern React it is a JavaScript function whose name starts with a capital letter and that returns JSX describing what should appear on screen.

  3. Why must React component names start with a capital letter?

    JSX uses capitalization to distinguish components from HTML elements: lowercase tags (e.g. <div>) are treated as built-in DOM elements, while capitalized tags (e.g. <MyComponent>) are treated as user-defined components.

  4. What tool does The Odin Project recommend for scaffolding a new React project, and what command creates one?

    Vite. Run: npm create vite@latest my-app -- --template react, then cd into the folder, run npm install, and start the dev server with npm run dev.

  5. In a Vite React project, what are the roles of index.html, main.jsx, and App.jsx?

    index.html is the single HTML page containing a root div; main.jsx grabs that root element, creates a React root with createRoot, and renders the app into it; App.jsx is the top-level application component.

  6. What is JSX?

    A syntax extension for JavaScript that lets you write HTML-like markup inside JavaScript files. It is syntactic sugar for React.createElement calls and must be transpiled (e.g. by Babel or Vite) before browsers can run it.

  7. List the three core rules of JSX.

    1) Return a single root element (wrap siblings in a parent or a Fragment <>...</>). 2) Explicitly close all tags, including self-closing ones like <img />. 3) Use camelCase for most attributes (className, onClick, htmlFor) since JSX attributes become JavaScript object keys.

  8. Why do you write className instead of class in JSX?

    JSX is compiled to JavaScript, where 'class' is a reserved keyword. Attribute names become keys on a props object, so React uses the DOM property name className instead.

  9. How do you embed a JavaScript expression inside JSX?

    Wrap it in curly braces, e.g. <h1>{user.name}</h1>. Curly braces work as text inside tags or as attribute values; double curlies like style={{ color: 'red' }} are just an object literal inside JSX braces.

  10. What is a React Fragment and why is it used?

    A wrapper (<React.Fragment> or the shorthand <>...</>) that lets you group multiple sibling elements without adding an extra node to the DOM, satisfying JSX's single-root-element rule.

  11. What are props in React?

    Read-only inputs passed from a parent component to a child, received as a single object argument (commonly destructured). They let parents configure children and are the primary way data flows between components.

  12. What is one-way (unidirectional) data flow in React?

    Data is passed only from parent to child via props. A child cannot directly modify its parent's data; to communicate upward, the parent passes a callback function as a prop that the child invokes.

  13. How does a child component send data or events back to its parent?

    The parent defines a function (often a state setter or handler) and passes it to the child as a prop; the child calls that callback, optionally with arguments, which runs the function in the parent's scope.

  14. How do you give a prop a default value in a function component?

    Use default values while destructuring the props parameter, e.g. function Button({ text = 'Click me' }) { ... }. The default applies when the prop is undefined.

  15. What is the 'children' prop?

    A special prop containing whatever is placed between a component's opening and closing tags, e.g. <Card><p>Hi</p></Card>. It enables composition, letting components wrap arbitrary content.

  16. How do you render a list of items in JSX?

    Call the array's map method to transform each item into a JSX element, e.g. {items.map(item => <li key={item.id}>{item.name}</li>)}, giving each element a unique key prop.

  17. What are the two main ways to conditionally render JSX?

    1) The ternary operator: {isDone ? <Done /> : <Pending />}. 2) The logical AND operator: {isVisible && <Modal />}. You can also use if statements outside the JSX or return null to render nothing.

  18. What is a common pitfall of using && for conditional rendering with numbers?

    If the left side is 0 (e.g. {count && <List />}), React renders the 0 itself rather than nothing, because 0 is falsy but still a renderable value. Use an explicit comparison like count > 0 && ... instead.

  19. What happens when a component returns null?

    React renders nothing for that component. It is a valid way to conditionally hide a component's output entirely.

  20. What is the purpose of the key prop in React lists?

    Keys uniquely identify sibling elements so React's diffing algorithm can tell which items were added, removed, or reordered, allowing it to update the DOM efficiently and preserve component state correctly.

Show the other 29 React flashcards
  1. Why is using an array index as a key considered an anti-pattern?

    If the list is reordered, filtered, or items are inserted/removed, indexes shift so keys no longer identify the same items. React then mismatches state and DOM nodes, causing bugs and unnecessary re-renders. Indexes are acceptable only for static lists that never change.

  2. What are the rules for choosing good keys?

    Keys must be unique among siblings and stable across renders — ideally IDs from your data or database. Do not generate keys during render (e.g. key={crypto.randomUUID()} inline), because a new key every render forces React to recreate the element and lose its state.

  3. What is state in React?

    A component's memory: data that persists between renders and, when updated, triggers React to re-render the component. It is managed with hooks like useState in function components.

  4. Describe the useState hook and its return value.

    const [value, setValue] = useState(initialValue). It returns an array with the current state value and a setter function; calling the setter schedules a re-render with the new value. The initial value is used only on the first render.

  5. What are the Rules of Hooks?

    1) Only call hooks at the top level of a function component or custom hook — never inside loops, conditions, or nested functions. 2) Only call hooks from React function components or custom hooks, not regular JavaScript functions.

  6. Why should you never mutate state directly in React?

    React compares state references to decide whether to re-render; mutating an object or array in place keeps the same reference, so React may not detect the change. Always call the setter with a new value, e.g. a copied object ({ ...obj, key: val }) or array ([...arr, item]).

  7. What does it mean that state updates are asynchronous and that renders capture a 'snapshot' of state?

    Calling a setter does not change the state variable in the currently running code; it schedules a re-render. Each render's functions see the state values from the render they were created in, so reading state right after setting it still gives the old value.

  8. What is an updater function in setState, and when should you use it?

    Passing a function to the setter, e.g. setCount(prev => prev + 1), makes React compute the new state from the latest pending state. Use it when the new state depends on the previous state, especially for multiple updates in one event handler.

  9. What is state batching in React?

    React groups multiple state updates that occur in the same event handler (and, since React 18, in promises and timeouts too) into a single re-render for performance, instead of re-rendering after each setter call.

  10. What triggers a React component to re-render?

    A change to its own state (via a setter), a re-render of its parent (which re-renders children by default), or a change in context it consumes. Props changing is a consequence of the parent re-rendering.

  11. What does 'lifting state up' mean?

    Moving shared state to the closest common ancestor of the components that need it. The ancestor passes the state down as props and passes setter callbacks so children can update it, keeping a single source of truth.

  12. What is a controlled component (controlled input)?

    A form element whose value is driven by React state: the input's value prop is set from state and its onChange handler updates that state, making React the single source of truth for the input's contents.

  13. What is a side effect in React, and which hook handles them?

    Any operation that reaches outside the rendering calculation — fetching data, timers, subscriptions, directly manipulating the DOM. The useEffect hook runs such code after the component renders.

  14. Explain the three parts of useEffect(callback, dependencies).

    The callback runs after render and contains the effect; it may return a cleanup function that runs before the effect re-runs and when the component unmounts; the dependency array controls when the effect re-runs (only when a listed value changes).

  15. How does the useEffect dependency array change when the effect runs?

    No array: the effect runs after every render. Empty array []: it runs only once after the initial mount (plus cleanup on unmount). Array with values [a, b]: it runs after mount and whenever any listed value changes.

  16. When does a useEffect cleanup function run, and give a typical use case.

    It runs before the effect executes again and when the component unmounts. Typical uses: clearing intervals/timeouts (clearInterval), removing event listeners, or aborting/cancelling subscriptions and fetches to prevent memory leaks.

  17. When should you NOT use useEffect?

    When a value can be computed from existing props/state during render (derive it instead), when responding to a user event (put the logic in the event handler), or to 'sync' state to other state. Effects are for synchronizing with external systems only.

  18. In the CV Application project pattern, how is switching between edit mode and display mode implemented?

    With a boolean piece of state (e.g. isEditing). Conditional rendering shows a form with controlled inputs when true and a read-only display of the submitted data when false; submitting the form updates state and flips the flag.

  19. In the Memory Card project, what causes the cards to re-shuffle and how is the score tracked?

    Clicking a card updates state (e.g. a list of already-clicked card IDs), which triggers a re-render that shuffles the card array. If the clicked card is already in the list, the current score resets and best score is updated; otherwise the score increments.

  20. How do you define a class-based React component?

    Create a class that extends React.Component with a render() method returning JSX. State is initialized in the constructor (after calling super(props)) as this.state, and updated with this.setState(); props are accessed via this.props.

  21. Why do class component event handlers often need bind (or arrow functions)?

    When a method is passed as a callback, it loses its 'this' binding, so this.setState would be undefined. Fix it by binding in the constructor (this.handleClick = this.handleClick.bind(this)) or defining the handler as a class-field arrow function.

  22. Name the three main lifecycle phases of a class component and their key methods.

    Mounting: constructor → render → componentDidMount. Updating (props or state change): render → componentDidUpdate. Unmounting: componentWillUnmount, used for cleanup like removing listeners or timers.

  23. How does useEffect map onto class lifecycle methods?

    useEffect with [] ≈ componentDidMount; useEffect with dependencies ≈ componentDidUpdate for those values; the effect's returned cleanup function ≈ componentWillUnmount. One hook can replace all three.

  24. Which libraries does The Odin Project use for React testing, and what does each do?

    Vitest (or Jest) as the test runner/assertion framework, React Testing Library (@testing-library/react) to render components and query the DOM as a user would, and @testing-library/user-event to simulate realistic user interactions like clicks and typing.

  25. In React Testing Library, what is the difference between getBy, queryBy, and findBy queries?

    getBy* throws an error if no match is found (use when the element should exist); queryBy* returns null instead of throwing (use to assert absence); findBy* returns a promise and waits for the element (use for elements that appear asynchronously).

  26. Why does React Testing Library recommend queries like getByRole over test IDs or CSS selectors?

    Querying by accessible role, label, or text tests the component the way users (and assistive technology) experience it, making tests more robust to implementation changes and encouraging accessible markup. Test IDs are a last resort.

  27. What is a mock function in testing, and why mock callback props?

    A fake function (e.g. vi.fn() or jest.fn()) that records how it was called. Passing it as a callback prop lets you assert the component invoked it correctly (toHaveBeenCalled, call counts, arguments) without running real logic — isolating the component under test.

  28. What is PropTypes and how do you declare a required string prop?

    A runtime type-checking library (the prop-types package) for component props that logs console warnings in development when props have wrong types. Declare with: MyComponent.propTypes = { name: PropTypes.string.isRequired }. Non-required props can get fallbacks via defaultProps or default parameters.

  29. What are the core building blocks of React Router for client-side routing?

    createBrowserRouter (defines an array of { path, element } route objects), RouterProvider (supplies the router to the app), <Link to="..."> for navigation without full page reloads, <Outlet /> to render child routes inside a parent layout, useParams to read dynamic URL segments like :id, and errorElement for unmatched/error routes.

The Odin Project React FAQ

What is in the The Odin Project React syllabus?

The Odin Project React is split into 6 chapters: Getting Started With React, States And Effects, Class Components, React Testing, The React Ecosystem and More React Concepts. Together they contain 24 topics.

How many chapters are in The Odin Project React?

6 chapters, containing 24 topics. The largest chapter is Getting Started With React, with 7 topics.

Are there flashcards for The Odin Project React?

Yes — a 49-card React 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.