The problem React solves
In the DOM section, you learned how to build interactive pages with vanilla JavaScript — selecting elements, updating text, creating nodes, attaching event listeners. It works, but it doesn’t scale.user changes, React automatically updates the UI to match the new state. In day-to-day React UI code, you usually stop doing manual DOM updates with document.querySelector and element.textContent.
Components: the building blocks
React apps are made of components — reusable, self-contained pieces of UI. Each component is a JavaScript function that returns what should appear on screen.If you’ve used Python classes, think of components like classes with a
render method (though React components are actually just functions). Each one manages its own piece of the UI.How React updates the page
React uses a Virtual DOM — a lightweight copy of the real DOM that lives in memory.- Your component renders and returns JSX (a description of the UI)
- React creates a Virtual DOM from that JSX
- When state changes, React re-renders the component and creates a new Virtual DOM
- React diffs the old and new Virtual DOMs
- React applies only the minimal changes to the real DOM
Why React (specifically)
There are other frameworks (Vue, Angular, Svelte), but React dominates because:- Massive ecosystem — solutions exist for almost every problem
- Job market — the most in-demand frontend skill
- Stability — backed by Meta, used by millions of apps
- React Native — the same concepts work for mobile apps
- Community — Stack Overflow, tutorials, and libraries everywhere
The mental model shift
| Vanilla JavaScript | React |
|---|---|
| Imperative: Tell the browser how to update | Declarative: Tell React what the UI should be |
| You manage DOM updates manually | React manages DOM updates for you |
| State scattered across DOM elements | State lives in component variables |
| Event listeners attached manually | Event handlers passed as props |
| Hard to keep UI in sync with data | UI always reflects current state |
What you need to know
Here’s the truth about React that nobody tells beginners: 90% of React development uses just a handful of concepts. The essentials you’ll learn in this section:- Components & JSX — building blocks of the UI
- Props — passing data into components
- useState — managing data that changes
- useEffect — fetching data and side effects
- Conditional rendering — showing/hiding UI based on state
- List rendering — displaying arrays of data
- Forms — handling user input
- Component composition — organizing your app
What’s next?
Let’s get a React project running on your machine. In under 2 minutes you’ll have a live development server with hot reload.Setting up a React project
Create a new React project with Vite