Skip to content
Getting StartedChapter 1 / 37Beginner4 min read

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.

UI = a combination of small parts
Navbar
Product Card
Shopping Cart
Footer
Complete UI

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 ReactWith React
User actionState / data changes
Find the DOM manuallyReact detects the change
Update every element yourselfThe UI updates automatically
Code gets complex quicklyA UI organized with components + state
React's simple flow
State/Data change
React
UI update

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:

AreaWhat is built with React
E-commerceProduct cards, cart, filters, checkout UI
DashboardTables, charts, filters, interactive panels
SaaS appsSettings, forms, modals, user dashboards
Social appsPosts, 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.

From user action to UI
User Action
State/Data Change
React re-render
UI update

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:

tsx
function Welcome() {
  return <h1>Hello React</h1>;
}

How does the code work?

ItemMeaning
WelcomeA React Component (a reusable piece of UI)
return (...)JSX, HTML-like syntax that describes the UI
On the screenThe heading Hello React is shown

In a real app, multiple components are combined:

Component tree (simple)
App
Navbar
ProductList
ProductCard

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.

TopicPropsState
Where it comes fromThe parent componentInside the component itself
Who changes itThe parent (read-only for the child)The component itself (user action, API, etc.)
When to usePassing data downUI 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

StageTopics
BeforeHTML/CSS basics, JavaScript basics, functions, arrays & objects, map(), import / export
Related (alongside React)Components, JSX, Props, State, Events, Hooks
AfterAPI integration, routing, advanced Hooks, Next.js
Suggested order
JavaScript
React.js
Components + JSX
Props + State
Hooks
API Integration
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

PointDetail
What React isA JavaScript library for building UI
UI structureReusable Components
Update triggerState / data change
Data between ComponentsProps