What is React?
Table of Contents + β
Welcome to the very first lesson of the React Tutorials. Before we touch any code, letβs answer the one question everything else builds on: what exactly is React?
π€ Why Should You Even Care About React?
Picture building a website the old way, with plain JavaScript. Here is what that turns into:
- You grab a piece of the page and change its text. Then you grab another piece and change a color.
- Then the data changes again, right? So now you have to remember every single spot on the screen that needs updating.
- Miss one spot, and the page shows the wrong thing.
That is the pain. Keeping what the user sees in sync with your data by hand gets messy fast.
React solves this in one line. You describe what the screen should look like for your data, and React updates the page for you whenever that data changes.
π§± So What Is React, Really?
React is a free, open-source JavaScript library for building user interfaces. Let us unpack that slowly, because each word matters:
- Free and open-source means anyone can use it and read its code. You never pay for it. It was created by Meta, the company behind Facebook, and a huge community helps improve it.
- JavaScript library means it is a set of ready-made tools you pull into your own JavaScript code. A library is like a toolbox, so you stay in charge and reach for the tools when you need them.
- User interface is just the part of an app a person sees and clicks. The buttons, the text, the menus, the images. People shorten βuser interfaceβ to UI.
So in plain words: React is a toolbox for building the screens of a website or app. It is used mostly for the front end, the part that runs in the browser and that the user looks at and touches.
Note
React is a library, not a full framework. A framework tries to give you everything and decide how your whole app is built. A library like React focuses on doing one job really well. It builds the UI and leaves other choices to you.
π§© The Big Idea: Build With Small Reusable Blocks
Here is the heart of React. You do not build a page as one giant block of code. Instead you break the screen into small pieces called components:
- A component is a self-contained piece of UI. Think of a single button, a search bar, or a profile card.
- Think of building with toy blocks. You snap a small set of them together to build something big.
- Build a block once, then reuse it again and again wherever you need it.
A real screen is just components placed inside other components. Imagine a simple chat app:
See how ChatItem appears three times? You wrote it once and reused it for every chat in the list. So you write less repeated code, and a change in one place updates every copy.
Here is the smallest possible component, just so the idea feels real. This one shows a friendly greeting on the screen.
function Welcome() { return <h1>Hello, welcome to React!</h1>;}That is a component. Notice a few things about it:
- It is a function that returns a small piece of UI.
- Do not worry about the exact rules yet, right? That is what the next lessons are for.
- For now, just hold onto the shape: a named function that gives back something to show.
π React Keeps the Screen in Sync With Your Data
The second big idea saves you a lot of work. In React, you do not reach into the page and change things by hand. Here is how it works instead:
- You keep your data in one place, then you tell React how the screen should look for that data.
- When the data changes, React figures out what is different. So it updates only the parts of the page that need it.
- React does this using a virtual DOM, which is a lightweight copy of the page that it compares against to spot the changes.
A light switch is a good way to picture it. You flip the switch and the light follows. You never walk over and adjust the bulb yourself. With React, your data is the switch and the screen is the light. Change the data, and the screen follows on its own.
This automatic updating is why React feels fast, and it is also why your code stays clean. You stop writing βfind this element, change that textβ instructions everywhere.
π Who Actually Uses React?
React is not a small experiment. It runs some of the most visited apps in the world, which means learning it is a real, useful skill.
| App | What you use it for |
|---|---|
| The site where React was first built and used | |
| The photo and reels app, built with React | |
| Netflix | Parts of the streaming interface you browse |
| WhatsApp Web | The browser version of the chat app |
When such large apps trust React for their UI, you know it can handle both tiny projects and huge ones.
π React and Single-Page Apps
You will often hear React used together with the term single-page app. Here is what that means:
- A single-page app, or SPA, is a website that loads one page once.
- After that, it updates the content right inside the page as you click around.
- It never does a full page reload each time.
Think of WhatsApp Web. You click a chat and the messages appear. You click another chat and those messages appear. The page never blinks or reloads. That smooth feeling is what React is great at building.
β οΈ Common Mistakes
A few wrong ideas trip people up on day one. Clear these up now and the rest of the course is smoother.
- Thinking React is a programming language. It is not. React is a library written in JavaScript, and you use it by writing JavaScript. So you still need to know basic JavaScript.
- Thinking React is a full framework. React focuses on the UI. For things like routing between pages or talking to a server, you add other tools alongside it.
- Thinking you need to learn everything before building. You do not. You will start with small components very soon and grow from there.
- Confusing React with React Native. React builds websites. React Native is a related tool for building phone apps. This course is about React for the web.
β Best Practices
You are not writing code yet, so these are mindset habits to carry into the next lessons.
- Keep your JavaScript basics fresh, since React sits on top of them.
- Start thinking in pieces. When you look at any app, try to spot the small repeated blocks.
- Be patient with new words like component and UI. Each one gets defined as you go.
- Build tiny things first. A small working component teaches more than reading for hours.
π§© What Youβve Learned
You now have the big picture before writing a single line of setup.
- β React is a free, open-source JavaScript library from Meta for building user interfaces.
- β It is used mostly for the front end, the part of an app the user sees and clicks.
- β You build the UI out of small reusable pieces called components.
- β React keeps the screen in sync with your data, so you do not update the page by hand.
- β Huge apps like Facebook, Instagram, Netflix, and WhatsApp Web are built with React.
- β React shines at single-page apps, where content updates without a full page reload.
Check Your Knowledge
Test what you learned. Pick an answer for each question, then click Check.
- 1
What kind of tool is React?
Why: React is a free, open-source JavaScript library, created by Meta, used to build user interfaces.
- 2
In React, what is a component?
Why: A component is a self-contained, reusable piece of UI, like a button or a card, that you can use again and again.
- 3
How does React keep the screen correct when your data changes?
Why: You describe the UI for your data, and React updates only the parts of the page that need to change.
- 4
Which of these is built with React?
Why: Instagram, along with Facebook, Netflix, and WhatsApp Web, uses React for its user interface.
π Whatβs Next?
Now you know what React is. The natural next question is why it is worth your time to learn it over the other options out there. Let us answer that head on.