Lesson 1
10 min
Understand what React is, the idea of components and what you need to know before starting.
Definition
React is an open-sourceJavaScript librarythat allows you to build user interfaces from small, independent, reusable blocks called components. Rather than directly modifying the elements of a page, you describe what the user should see based on the current data. React then takes care of updating the interface: this is a declarativeapproach.
Welcome to this introductory React course. Before writing code, it is important to understand what this library is, how it works, and why it is used in so many web applications.
This first lesson will give you a general overview of React. You will discover components, the declarative approach, the advantages of this technology, and the knowledge required to start using it. The concepts covered here will serve as a foundation for the following lessons.
React is an open-sourceJavaScript libraryoriginally developed at Facebook, now Meta. It allows you to create interactive user interfacesfor websites and applications. It is particularly suitable for interfaces that change frequently in response to user actions.
A user interface includes everything you see and interact with in an application: buttons, menus, forms, lists, cards, and the different sections of a page. React allows you to organize these elements in a clear and reusable way.
For example, in an online store, React can display products, update the shopping cart when you add an item, and automatically change the total amount. In a task management application, it can add or remove items without requiring a complete page reload.
React is generally described as a libraryrather than a complete framework. This means that it focuses mainly on creating and updating the user interface. For other features, such as navigation or certain server operations, you can use additional tools.
This approach offers great flexibility. You can start with a simple application, then gradually add the tools you need. React also integrates with different environments and can be used in projects of many different sizes.
With React, an interface is divided into small blocks called components. A component can represent a button, a card, a form, a navigation bar, or even an entire page. These components can then be assembled to build a complete application.
Imagine a set of building blocks: each piece has a specific purpose and can be reused several times. AButtoncomponent can appear in different places with different text or actions, without having to rewrite its entire structure.
This organization makes code maintenance easier. If you change the appearance of a component reused across several pages, the changes can be applied everywhere that component is used. This helps maintain a consistent interface and reduces repetition.

React components are organized into a hierarchical structure called a component tree. A main component can contain several child components, which can themselves contain other components.
App
├── Header
│ ├── Logo
│ └── Navigation
├── ProductList
│ ├── ProductCard
│ ├── ProductCard
│ └── ProductCard
└── FooterIn this example, the main componentAppcontains the header, a list of products, and the footer. Each product card can be built from the same component while displaying different information.
A simple React component can be written as a JavaScript function. This function returns a description of the interface to display, usually written using a syntax called JSX.
function Welcome() {
return <h1>Hello!</h1>;
}
export default Welcome;Here, theWelcomecomponent simply displays a heading. Although the code looks like HTML, it is actually JSX, a syntax used with JavaScript. You will learn to use it in more detail in the following lessons.
In plain JavaScript, you can directly modify the elements of a page: find an element, change its text, or add a CSS class. With React, you instead describewhat the interface should displaybased on the available data.
This way of programming is called adeclarative approach. You define the expected result, and React takes care of updating the necessary parts when the data changes. You therefore do not need to manually manipulate every element on the page.
Imagine a button that increases a counter with every click. In plain JavaScript, you can find the element containing the number and directly change its content. With React, you store the counter value in data calledstate.
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Clicks: {count}
</button>
);
}
export default Counter;In this example,useStatestores the counter value. When the user clicks, the value increases and React automatically updates the display. You do not need to find the button to change its text.
You do not need to understand every line of this example immediately. Simply remember that React connects data and the display. When the data changes, the interface reflects its new value.
A dynamic interface is an interface that can change in response to user actions or new data. It does more than display static content.
React is particularly useful for these interfaces because it allows you to represent different visual states based on data. You can therefore build interactive applications while keeping your code organized.
These advantages explain why React is widely used in web development. Components make it easier to create increasingly complex projects, while the declarative approach simplifies the management of interface changes.
Learning React also helps you develop skills useful in many projects. You will be able to build your own applications, contribute to collaborative projects, or deepen your knowledge of front-end development.
React can be used to create many different types of interfaces: dashboards, online stores, social networks, educational platforms, management tools, and interactive applications.
It is suitable for both personal projects and professional applications. You can start with a simple counter, a calculator, or a task list, then gradually build more complete applications.
With React Native, React principles can also be used to develop mobile applications for Android and iOS. However, the components used are different from those in the browser, because they rely on native elements.
React does not replace the fundamental knowledge of web development. It builds onHTML, CSS, and JavaScript, which remain essential for understanding how an application works.
For example, in React, you can write a structure that resembles HTML, apply CSS styles to it, and use JavaScript to manage events and data. These technologies therefore work together.
Prerequisites
This course assumes that you know the basics of HTML,CSS, and JavaScript: variables, functions, arrow functions, arrays, objects, destructuring, and methods such asmapandfilter. If necessary, start with the HTML, CSS, and JavaScript courses in the catalog.
Over 12 lessons, you will learn how to set up a React project, write JSX, create components, use props, manage state and events, display lists, build forms, and communicate with an API.
You will also discover theuseStateanduseEffecthooks, then learn how to create your own hooks. All these concepts will then come together in a final project: a complete task management application.
Before starting the next lessons, here are some terms you will encounter frequently. You do not need to master them immediately, but recognizing them will make learning easier.
These concepts are connected to one another. A component can receive information through props, store values in its state, and display the result using JSX. You will gradually discover how they work together in an application.
Some concepts, such as state or hooks, may seem abstract at first. They become easier when you use them in practical examples. So do not hesitate to repeat the exercises several times.
A good method is to read an explanation, reproduce the code, then modify one element to observe its effect. This active practice is generally more effective than simply reading the examples.
By the end of this course, you will be able to build a small React application organized into components. You will be able to display data, respond to user interactions, and manage information that changes over time.
To get started, look at the applications you use every day. Try to identify the parts that could be turned into components: buttons, menus, cards, lists, search fields, and forms.
Exercise
Go Further