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.
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);function Counter() {
const [count, setCount] = useState(0);
// Describe the UI for any value of count. React does the updating.
return <button onClick={() => setCount(count + 1)}>Clicked {count} times</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.
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:
Something happens: a click, a keystroke, data arriving. Your code asks React to update the state.
You never write the "find this element and change it" code. That entire class of bugs (forgetting to update one place) disappears.
Put one React update in order.
- Tap the steps below in the right order.
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
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.
2012
Instagram
Instagram's web app adopts it, which pushes Facebook to separate React from its internal code.
2013
Open source at JSConf US
Released publicly. JSX draws heavy criticism at first.
2015
React Native
The same component model, rendering to native iOS and Android views instead of the DOM.
2017
Fiber (React 16)
A rewrite of React's core so rendering work can be split up, paused and prioritised.
2019
Hooks (React 16.8)
`useState`, `useEffect` and friends let function components hold state. Class components fade out of new code.
2022
Concurrent rendering (React 18)
React can prepare a new UI in the background and interrupt low-priority updates to keep typing smooth.
2024
React 19
Actions for forms, `useActionState`, `use`, and stable Server Components for frameworks like Next.js.
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.Componentin 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 each milestone to what it gave you.
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 point | Use it when |
|---|---|
Vite (npm create vite@latest) | A client-side app or learning project. Fast dev server, no opinions. |
| Next.js | Full-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. |
| Expo | Mobile 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.
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.
- 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
useStatethat 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.