Introduction
Learn what React.js is, why it is used, and how it builds user interfaces with Components and State, a beginner-friendly introduction.
On this page
1. What is React?
Definition
In simple words, React divides the UI into small reusable Components. Each Component does one specific job in the UI, and you combine these Components to build a complete application.
React.js is part of the JavaScript ecosystem and is mainly used for frontend UI development.
2. Why does it matter?
What problem does it solve?
In traditional JavaScript, updating a complex UI manually can be difficult, for example when several UI elements must update together after a user action.
| Without React | With React |
|---|---|
| User action | State / data changes |
| Find the DOM manually | React detects the change |
| Update every element yourself | The UI updates automatically |
| Code gets complex quickly | A UI organized with components + state |
React makes it easier to organize and manage a complex UI through Components and State.
3. Where is it used?
React is used wherever you need an interactive UI:
| Area | What is built with React |
|---|---|
| E-commerce | Product cards, cart, filters, checkout UI |
| Dashboard | Tables, charts, filters, interactive panels |
| SaaS apps | Settings, forms, modals, user dashboards |
| Social apps | Posts, likes, comments, notifications |
React is also used inside frameworks like Next.js (along with routing, SSR and a production setup).
4. How does it work?
Basic mental model
The basic idea of React is that the UI is rendered according to the current data / state.
Example: The user presses the Like button → the state changes → React renders the component again → the updated like count appears on the screen.
5. Code example
In React you write the UI in the form of Components:
function Welcome() {
return <h1>Hello React</h1>;
}How does the code work?
| Item | Meaning |
|---|---|
Welcome | A React Component (a reusable piece of UI) |
return (...) | JSX, HTML-like syntax that describes the UI |
| On the screen | The heading Hello React is shown |
In a real app, multiple components are combined:
6. Common mistakes
Mistake: Building one huge Component
Why? The code becomes hard to understand and maintain.
Better: Divide the UI into small, reusable Components, with one clear job for each part.
Mistake: Making everything State
Why? Extra state code is confusing and sometimes hurts performance too.
Better: Keep only the data that changes in the UI in State, and use normal variables or props for the rest.
Mistake: Mixing up Props and State
Why? They play different roles, and using the wrong one causes bugs.
Better: Props = data that came from the parent; State = the component's own changing data.
| Topic | Props | State |
|---|---|---|
| Where it comes from | The parent component | Inside the component itself |
| Who changes it | The parent (read-only for the child) | The component itself (user action, API, etc.) |
| When to use | Passing data down | UI that is changing |
Mistake: Thinking React is just a way to write HTML
Why? The real benefit is in Components, State, Props and a data-driven UI.
Better: Understand the mental model first, and the JSX syntax comes naturally later.
7. What to learn before and after
Learning path
| Stage | Topics |
|---|---|
| Before | HTML/CSS basics, JavaScript basics, functions, arrays & objects, map(), import / export |
| Related (alongside React) | Components, JSX, Props, State, Events, Hooks |
| After | API integration, routing, advanced Hooks, Next.js |
Final quick revision
In simple words
React.js is a JavaScript library used to build interactive UI. The UI is divided into Components; when state / data changes, the UI updates.
Key points
| Point | Detail |
|---|---|
| What React is | A JavaScript library for building UI |
| UI structure | Reusable Components |
| Update trigger | State / data change |
| Data between Components | Props |