← Learning Hub
Beginner

React Introduction

React is a JavaScript library for building user interfaces. You build a page from small pieces called components, like Lego blocks: a header, a product card, a cart button.

When your data changes, React updates only the part of the page that needs to change. You just describe what the page should look like.

Modern websites like Instagram, Swiggy and Netflix change constantly as you use them: likes update, cart counts change, new posts load. Updating the page by hand with plain JavaScript (find this element, change its text, add that element...) quickly gets complicated and buggy. React was created at Facebook to solve exactly this problem.

React's big idea: the UI is a function of the data. You write components that say "given this data, the page looks like this". When the data changes, React works out the smallest set of changes to the real page and applies them. You think about what to show, not how to update it.

React is one of the most in-demand front-end skills in job posts. It's a library focused on the user interface, so for things like page routing or data loading you add other libraries - which is why the React world has many tools to choose from.

Here is a full page with React. Press Try it yourself and change the text:

Example
<!DOCTYPE html>
<html>
  <body>
    <div id="root"></div>

    <script src="https://unpkg.com/react@18.3.1/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/@babel/standalone@7.24.7/babel.min.js"></script>

    <script type="text/babel">
      function App() {
        return <h1>Hello from React!</h1>;
      }

      ReactDOM.createRoot(document.getElementById("root")).render(<App />);
    </script>
  </body>
</html>
▶ Try it yourself
Before React, learn the basics of HTML, CSS and JavaScript. React is JavaScript, so those skills are used everywhere.
In real projects you install React with a tool such as Vite (see the last lesson). Here the editor loads React from the internet so you can practise straight away.
Key points
  • React builds UIs from reusable components.
  • You describe what the UI looks like for the current data; React updates the page.
  • Learn HTML, CSS and JavaScript first.
  • Real projects are created with tools like Vite.

📝 Test yourself

1. What is React used for?
2. What are the small reusable pieces of a React page called?
3. Which language do you write React in?