Skip to content

Lesson 1 of 37Thinking in React

The React Story

Learn why React exists, what problem it solved at Facebook, and how its declarative model works.

12 min read0/4 questions

The JavaScript & TypeScript course gave you the language. This track uses it to build interfaces. React is the most used UI library on the web. It runs Facebook, Instagram, Netflix's browse screens, Discord, and a huge share of the job listings you will apply to. Knowing why it was built makes every later idea (components, state, re-rendering) feel obvious instead of magic.

The problem: UI that changes

In 2011, Facebook's web app had a problem that sounds small and is not. Pages like the News Feed and the ads management tools changed constantly: a new comment arrives, a like count ticks up, a chat window opens, a budget field updates three other fields. Every change meant code like "find this element, change its text, then hide that other element, then update the badge".

That style is called imperative: you write the step-by-step instructions to move the page from its old state to its new one. With a handful of features it is fine. With hundreds, nobody can keep track of which code touches which element, and bugs appear where two updates disagree (the badge says 3, the list shows 2).

A Facebook engineer named Jordan Walke built a prototype (first called FaxJS) with a different idea: what if you never updated the page by hand? You just describe what the page should look like for the current data, and the library figures out the changes.

Imperative vs declarative

Here is the same tiny feature both ways: a button that shows how many times it was clicked.

const button = document.createElement("button");
let count = 0;
button.textContent = "Clicked 0 times";
button.addEventListener("click", () => {
  count += 1;
  // You must remember to update every place that shows count.
  button.textContent = `Clicked ${count} times`;
});
document.body.appendChild(button);

The imperative version is a list of how to change things. The declarative one is a description of what the UI is for a given count. When count changes, React calls Counter again, gets a new description, and updates the page for you.

This is the core idea of React, often written as a formula:

UI = f(state). Your component is a function. Give it the current data (the state), and it returns what the screen should show.

Here is that counter, live. Edit the text, press Run, click the button.

React
import { useState } from "react"; export default function App() { const [count, setCount] = useState(0); return ( <button onClick={() => setCount(count + 1)}> Clicked {count} times </button> );}
Quick check
What does it mean that React is declarative?
Need a nudge? A hint rules out a wrong answer.

How React updates the page: the virtual DOM

Calling your component again on every change sounds slow. Touching the real DOM (the browser's live tree of elements) is slow compared with plain JavaScript. React's trick is to keep a lightweight copy.

The virtual DOM is a tree of plain JavaScript objects that describes the UI, like { type: "button", props: { children: "Clicked 3 times" } }. When state changes, React:

One update in React
  1. State changessetCount(4) is called
  2. RenderReact calls your component again and gets a new tree of objects
  3. Reconcile (diff)compare the new tree with the previous one
  4. Commitapply only the differences to the real DOM

Something happens: a click, a keystroke, data arriving. Your code asks React to update the state.

1/4

You never write the "find this element and change it" code. That entire class of bugs (forgetting to update one place) disappears.

Put it in order4 steps

Put one React update in order.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.

JSX: the controversial part

React components return markup that looks like HTML inside JavaScript. That syntax is called JSX. When React was shown at JSConf US in May 2013, many developers hated it. The rule at the time was "separate concerns": HTML in one file, JavaScript in another, and JSX broke it.

React's answer was that the real concern is the component. A button's markup, its logic and its behaviour change together, so keeping them together is the cleaner split. Within a few years, nearly every UI framework had adopted components, and JSX (or something like it) became normal. You will learn how JSX works in the next lesson.

The timeline

React from prototype to today
  1. 2011

    Prototype at Facebook

    Jordan Walke builds FaxJS to tame the News Feed and the ads tools. It ships in the News Feed later that year.

  2. 2012

    Instagram

    Instagram's web app adopts it, which pushes Facebook to separate React from its internal code.

  3. 2013

    Open source at JSConf US

    Released publicly. JSX draws heavy criticism at first.

  4. 2015

    React Native

    The same component model, rendering to native iOS and Android views instead of the DOM.

  5. 2017

    Fiber (React 16)

    A rewrite of React's core so rendering work can be split up, paused and prioritised.

  6. 2019

    Hooks (React 16.8)

    `useState`, `useEffect` and friends let function components hold state. Class components fade out of new code.

  7. 2022

    Concurrent rendering (React 18)

    React can prepare a new UI in the background and interrupt low-priority updates to keep typing smooth.

  8. 2024

    React 19

    Actions for forms, `useActionState`, `use`, and stable Server Components for frameworks like Next.js.

  9. 2025

    React Compiler 1.0

    A build step that memoises components automatically, so you write less manual optimisation code.

A few landmarks worth knowing by name:

  • Fiber is why React can stay responsive while rendering big trees. It splits work into small units it can pause.
  • Hooks replaced classes for almost all new code. You will write function components with hooks throughout this track. You may still meet class X extends React.Component in older codebases.
  • Server Components (React 19) run only on the server and send finished UI to the browser, so their code never ships to the user. Next.js is built around them, and the Next.js course covers them in depth.
Match the pairs0/4 matched

Match each milestone to what it gave you.

Choose an item, then its match on the other side.

React is a library, not a framework

React itself only does one job: turn components into UI and keep it in sync with state. It does not include routing (URLs to pages), data loading conventions, or a build setup. In 2026 you pick one of these to start a project:

Starting pointUse it when
Vite (npm create vite@latest)A client-side app or learning project. Fast dev server, no opinions.
Next.jsFull-stack web apps with server rendering, routing, Server Components. The most common choice in job postings.
React Router (formerly Remix)Web apps that want strong routing and data loading, with or without a server.
ExpoMobile apps with React Native.

Create React App, the old default starter, was officially deprecated in 2025. If a tutorial tells you to run create-react-app, it is out of date.

Quick check
You need a quick client-side React app to practice with. Which is the standard 2026 starting point?
Need a nudge? A hint rules out a wrong answer.

How this course is laid out

  • Thinking in React: JSX, components, props, lists, conditions and events, the building blocks of every screen.
  • State: useState, reducers and context, so components remember things and share them.
  • Effects and beyond: effects, refs, custom hooks, data fetching, how rendering works and how to keep it fast.
  • Modern React: transitions, Suspense, Actions, error boundaries and animation from React 19.
  • Real projects and React at scale: setup, TypeScript, styling, testing, stores, server state, routing, accessibility and debugging.

By the end you will be able to build, test and debug a production React app and explain your choices in an interview. The course closes with a wrap-up that ties it all together.

Key terms
declarative UI
You describe what the UI should look like for the current state, and the library works out the DOM changes.
imperative UI
You write the step-by-step DOM instructions to move from the old screen to the new one.
virtual DOM
A tree of plain JavaScript objects describing the UI. React diffs old and new trees to find the minimal DOM changes.
reconciliation
React's process of comparing the new render output with the previous one to decide what to update.
hooks
Functions like useState that let function components hold state and run side effects. Added in React 16.8 (2019).
Server Components
Components that render only on the server and ship no JavaScript to the browser. Stable in React 19.