Intermediate

React

Learn React from zero. Components, state, hooks, context, performance, routing, testing, and a capstone app.

17 lessons10.2h hands-on11 languages

17 lessons, in order

  1. 1

    What is React?

    Welcome. If you have never written a line of JavaScript and you are not sure what a "framework" is, you are in the right place. By the end of this...

    What React is, Components as functions, Virtual DOM intuition, Rendering JSX, Creating a Vite app

    25 min
  2. 2

    JSX and Components

    In the last lesson you saw a component return something that looked like HTML: return <h1>Hello, React</h1>;. That should have felt slightly wrong....

    JSX syntax rules, Single root element, className vs class, Embedding expressions with {}, Defining components, Composing components

    30 min
  3. 3

    Props

    Every component you have written so far has been hardcoded. Greeting always says hello to the same name, Card always shows the same text. That is...

    Passing props as attributes, Receiving props object, Destructuring props in signature, Default values, Thinking about prop shapes

    30 min
  4. 4

    State with useState

    Every component you have written so far renders the same output for the same props, every single time. That is fine for a heading or a card, but it...

    useState hook, Reading state, Calling the setter, Updater function form, Never mutate state, Counter pattern

    35 min
  5. 5

    Handling Events

    A component that only ever renders based on props and state is not interactive on its own, something has to notice when the user clicks a button,...

    onClick handler, onChange basics, Passing functions vs calling them, Event object, Passing handlers as props

    30 min
  6. 6

    Conditional Rendering and Lists

    Almost every screen you have ever used shows one thing instead of another depending on some condition: a "you have new messages" banner that only...

    && for show/hide, Ternary for either/or, Mapping arrays to JSX, The key prop, Why keys need to be stable

    30 min
  7. 7

    Forms and Controlled Inputs

    Type a letter into a plain HTML <input> and the browser just handles it: the DOM element quietly keeps track of what you typed, and nobody else needs...

    Controlled input pattern, Value and onChange together, multi-field form state, onSubmit and preventDefault, Gathering form data

    35 min
  8. 8

    Effects with useEffect

    A component's job, so far, has been to look at its current props and state and answer one question: what should be on screen right now. That answer...

    What counts as a side effect, useEffect signature, Dependency array, Running on mount only, Cleanup function, subscribe/unsubscribe pattern

    40 min
  9. 9

    Data Fetching

    Almost no real app can get by showing only data the user already has on their screen. At some point a component needs to ask a server for something,...

    fetch inside useEffect, loading/error/data states, AbortController cleanup, Preventing setState after unmount

    40 min
  10. 10

    Component Composition

    You have built a card with a border and a shadow, and it looks good. Now you need the same card around a photo, and around a login form, and around a...

    Children prop, Wrapping components, Passing JSX as props, Lifting state up, Thinking in component trees

    35 min
  11. 11

    Context and useContext

    Your app has a dark mode toggle. The toggle lives in the settings panel, but the thing that needs to know about it is a button eight components deep...

    createContext, Context.Provider, useContext, When context is the right tool, Context vs prop drilling tradeoffs

    35 min
  12. 12

    useReducer

    A checkout form starts simple. There is a value, so you add useState. Then it needs an error message, so that is another useState. Then a loading...

    When to reach for useReducer, Reducer function shape, Action objects, Dispatch, Combining useReducer with useContext

    35 min
  13. 13

    Custom Hooks

    You wrote a drawer that opens and closes. Three useState lines and a handler that flips a boolean. Then the same thing for a dropdown, and again for...

    Extracting stateful logic into a function, Use prefix convention, useToggle example, useLocalStorage example, Hooks rules

    35 min
  14. 14

    Performance and Memoization

    Your app has a table with two thousand rows and a search box above it. Every keystroke feels heavy: you type, and half a second later the letter...

    React.memo for components, useMemo for expensive computations, useCallback for stable function references, When memoization is overkill, Measuring before optimizing

    35 min
  15. 15

    Routing with React Router

    Everything you have built so far lives at one address. There is a single page, and whatever you want the user to see, you show or hide with state....

    Installing react-router-dom, BrowserRouter, Routes and Route, Link for navigation, useParams, useNavigate

    40 min
  16. 16

    Testing React Components

    You change one line in a shared component and then spend twenty minutes clicking around the app checking that nothing else broke. Next week you...

    Vitest + React Testing Library setup, Render and screen, getByRole queries, userEvent for interactions, Writing one good button test

    40 min
  17. 17

    Capstone: Todo App

    Every lesson so far handed you one idea at a time with a small example around it. Real apps are not like that. In a real app the state, the list...

    Combining state, lists, controlled inputs, Custom hook for localStorage persistence, Small routing setup, Putting it together

    60 min