Library / React / Module 1 ≡ All lessons
What React is and how this course works
React is a JavaScript library in which you describe the interface as a function of data: when the data changes, React updates the right parts of the page for you. In this lesson we look at why it exists, how it differs from plain JavaScript and how to get the most out of this course.
The problem React solves
Any page where something happens keeps data in mind: how many items are in the cart, which menu item is open, what the user typed into search. When the data changes, the page has to follow: update the number on the cart badge, highlight the menu item, show the search results.
Without libraries you do this by hand. You find an element on the page, change its text, add or remove classes, create new elements and insert them in the right place. With one button that is easy. With dozens of buttons, lists and forms, where a single user action has to change five places at once, the hand-written code turns into a tangle: it is easy to forget one element, and the interface starts showing contradictory things.
Here is a like counter in plain JavaScript:
let likes = 0;
const label = document.querySelector('#likes');
const button = document.querySelector('#like');
button.addEventListener('click', () => {
likes = likes + 1;
label.textContent = 'Likes: ' + likes; // don't forget to update the text
if (likes >= 3) {
document.querySelector('#thanks').hidden = false; // and one more place
}
});
We change the data and also tell the browser exactly which elements to fix. This style is called imperative: you command every step.
The same thing in React
React takes a different approach. You describe what the interface should look like for any data, not what to change on each click. When the data changes, React compares the new description with the old one and updates only what changed on the page. This style is called declarative.
The same counter in React:
import { useState } from 'react';
export default function LikeButton() {
const [likes, setLikes] = useState(0);
return (
<div className="box">
<p>Likes: {likes}</p>
<button onClick={() => setLikes(likes + 1)}>
👍 Like
</button>
{likes >= 3 && <p className="note">Thanks, you are our best reader!</p>}
</div>
);
}
Click the button in the preview a few times: on the third click a thank-you line appears. Notice that the code has
no “find the element and change its text” lines at all. There is only a description: show the number likes, and
if it is at least three, show the thank-you line too. useState keeps the number between clicks, and setLikes
tells React that the data changed and the interface needs an update. We will cover all of this in the
interactivity module. For now, catch the main idea: UI is a function of data.
What React does and what it doesn’t
React is responsible for one thing: the interface. It turns your components into page elements and keeps them in sync with the data. Everything else is handled by other tools that usually sit next to it:
- building the project — Vite or a framework;
- page addresses (routing) — React Router or a framework;
- loading data from a server — the built-in
fetch, libraries like TanStack Query or a framework’s server functions; - server rendering and SEO — React-based frameworks: Next.js, React Router in framework mode.
That is why React is called a library, not a framework: it does not dictate the structure of the whole app. This is handy for learning. First we master React itself, and the surrounding tools arrive in module 5, when we build a real project.
The course targets React 19, the current version. It brought forms with actions, the hooks useActionState,
useOptimistic and use, ref as a regular prop, and React Compiler that speeds up components on its own. Old
class components appear only so you can read other people’s code.
How the course works
The course has seven modules, from your first component to Server Components and choosing a framework. Every module has lessons and a project that ties together everything so far. The full curriculum is on the course page.
Every lesson follows the same shape:
- Short theory in plain language, in small steps.
- Live examples in the sandbox: code on the left, result on the right, a Console tab below.
- Common mistakes — call-outs about what trips almost everyone up.
- A summary as a list, for quick review.
- Homework with starter code and automatic checks. All green ticks mean the lesson is done.
- A question form at the bottom of the page in case something is still unclear.
Here is another example. It has a console.log: switch to the Console tab and see what the code printed. It also
shows the JavaScript you will need in the course: an array, an arrow function and the map method, which turns a
list of topics into a list of elements.
const topics = ['Components', 'JSX', 'Props', 'State'];
export default function Plan() {
console.log('Topics in the plan:', topics.length);
return (
<section>
<h2>Coming up in the first modules</h2>
<ol>
{topics.map((topic) => (
<li key={topic}>{topic}</li>
))}
</ol>
</section>
);
}
What to know before you start
React is JavaScript, so without the basics of the language it will be hard. Check yourself against the list. If it all looks familiar, you are ready. If something has faded, refresh it before module 2: one evening per item is enough.
- HTML tags and attributes, CSS basics and classes.
constandlet, strings, numbers,ifand the ternary operatora ? b : c.- Functions, including arrow functions:
(x) => x * 2. - Arrays and the methods
map,filter,find; objects and property access. - Destructuring
const { name } = userand template literals`Hi, ${name}`. - Modules:
importandexport.
Nothing to install yet. The first four modules run right in the browser; installing Node.js and creating a Vite project wait for you in module 5.
Summary
- React is a library for interfaces: you describe what the UI looks like for any data, and React updates the page.
- Changing the DOM by hand is the imperative style; React is declarative: UI is a function of data.
- Routing, builds and data loading are handled by other tools; we add them later.
- The course covers React 19: seven modules, lessons with a sandbox and homework, projects.
- You need the basics of HTML, CSS and JavaScript; nothing to install yet.
Next in the course: your first component, written in three lines.
Tell us about yourself in a component
Here is a business-card component. Put your name into the name variable, add at least four items
to the skills array and show their count in the <h2> heading with
{skills.length} rather than a typed number: then the count updates by itself when you add a
skill. Press Check when you are done.
// 1. Put your name instead of 'Anonymous'
// 2. Add at least 4 items to the skills array: things you can already do
// 3. In the h2 heading replace "?" with the number of skills: {skills.length}
const name = 'Anonymous';
const skills = ['HTML'];
export default function About() {
return (
<main>
<h1>Hi, I am {name}</h1>
<h2>Skills: ?</h2>
<ul>
{skills.map((skill) => (
<li key={skill}>{skill}</li>
))}
</ul>
</main>
);
}
Sign in with GitHub or Google to solve and check the homework. It is free.
- The h1 heading has your name, not "Anonymous"
- The list has at least four skills
- The h2 heading shows the exact number of skills
Saved solutions and completed-lesson marks arrive in your account in December.
FAQ
Is React a framework or a library?
A library: React only handles the user interface. Routing, builds and data loading come from other tools or from React-based frameworks such as Next.js.
What should I know before learning React?
HTML and CSS basics and core JavaScript: variables, functions, arrow functions, arrays and map, objects, destructuring, import and export.
Do I need to install anything to start?
No. The first modules run in the browser: examples and homework run in the built-in code sandbox. Node.js and Vite come in module 5.
Still have a question about this lesson?
Tell us what is unclear. The question goes to the author, and the answer to your email if you leave one. Later an AI tutor will answer here.