Introduction to React
Learn what React is, why it was created, and how its component-based, declarative approach changed front-end development.
Introduction
Modern web applications need to update the screen constantly — showing a new chat message, updating a shopping cart total, or reacting to a button click — all without reloading the whole page. Before React, keeping the on-screen HTML in sync with your data was something you had to manage by hand, and it got messy fast as applications grew.
React is a JavaScript library built specifically to make this kind of dynamic, constantly-changing UI manageable. It has become the most widely used tool for building user interfaces on the web, and this lesson introduces exactly what it is, the core ideas behind it, and why so many companies and developers rely on it.
- What React is and what problem it solves.
- The difference between declarative and imperative UI code.
- What the Virtual DOM is and why it makes updates fast.
- Why breaking UIs into components is so powerful.
- Where React is used in the real world.
What is React?
React is a JavaScript library for building user interfaces, created by Jordan Walke at Facebook (now Meta) and open-sourced in 2013. It is deliberately not a full framework — it does not ship with built-in routing, HTTP requests, or a specific project structure. Instead, React focuses on one job: letting you build UIs out of small, reusable, composable pieces called components.
Because React only handles the "view" layer, it is commonly paired with other tools — a router, a data-fetching library, and sometimes a state-management library — to build a complete application. This flexibility is one reason React has stayed popular across so many different kinds of projects.
UI Library, Not a Framework
React focuses purely on rendering components; you choose your own routing and tooling.
Declarative
You describe what the UI should look like for the current data, and React handles the DOM updates.
Component-Based
Interfaces are built from small, independent, reusable building blocks.
Learn Once, Write Anywhere
The same component model powers web apps (React DOM) and mobile apps (React Native).
- React lets you describe what the UI should look like for any given piece of data (state).
- When that state changes, React automatically figures out how to update the screen.
- UIs are built from small, reusable components rather than one giant HTML file.
Declarative vs Imperative UI
Before React, updating the DOM with plain JavaScript or jQuery usually meant writing imperative code: step-by-step instructions describing exactly how to find an element and change it. React instead encourages a declarative style: you describe the end result, and React works out the steps.
Imperative (manual DOM updates)
- const btn = document.createElement('button');
- btn.textContent = 'Count: 0';
- let count = 0;
- btn.addEventListener('click', () => {
- count++;
- btn.textContent = 'Count: ' + count;
- });
- document.body.appendChild(btn);
Declarative (React)
- function Counter() {
- const [count, setCount] = useState(0);
- return (
- <button onClick={() => setCount(count + 1)}>
- Count: {count}
- </button>
- );
- }
Notice the React version never manually selects an element or reassigns textContent. It simply says "the button's text is Count: {count}" — and whenever count changes, React takes care of updating the real DOM for you.
The Virtual DOM
Directly manipulating the browser's real DOM is relatively slow, especially when many things change at once. React keeps a lightweight, in-memory copy of the UI called the Virtual DOM. Whenever your data changes, React builds a new Virtual DOM tree, compares ("diffs") it against the previous one, and updates only the specific parts of the real DOM that actually changed.
State changes (e.g. setCount is called)
↓
React builds a new Virtual DOM tree
↓
React "diffs" it against the previous Virtual DOM
↓
React calculates the minimal set of real DOM changes
↓
Only the changed parts are updated in the browserWithout this diffing step, every small update could force the browser to re-render large sections of the page. The Virtual DOM lets React make updates surgical and fast, even in large applications.
Why Components Matter
Instead of writing one giant HTML file, React encourages you to break the UI into independent, reusable components — a button, a card, a navbar, a whole page — each managing its own logic, data, and appearance.
Reusability
Write a component once — a Button or a Card — and reuse it anywhere in your app.
Isolation
Each component manages its own logic, so bugs are easier to find and fix.
Readability
Breaking a UI into small, named pieces makes large applications far easier to understand.
Composability
Small components combine to build bigger ones, the same way HTML tags combine to build a page.
Where React Is Used
React was built at Facebook to solve real problems at massive scale, and it has since spread far beyond social media.
Facebook & Instagram
React was created to manage the constantly-updating News Feed and later powered Instagram's web app.
Netflix & Airbnb
Large consumer products use React to build fast, interactive interfaces at scale.
React Native
The same component model builds native iOS and Android apps.
Next.js & Remix
Full-stack frameworks built on top of React add routing, server rendering, and more.
Example: A First Look at React Code
You do not need to understand every detail yet — this is just a preview. Notice how the markup (JSX) and the logic (JavaScript) live together in one function.
function App() {
const framework = "React";
return (
<div>
<h1>Hello from {framework}!</h1>
<p>This UI is built from small, reusable components.</p>
</div>
);
}
export default App;Hello from React!
This UI is built from small, reusable components.Common Mistakes
- Thinking React is a full framework — it is a UI library, so routing and state management usually come from separate packages.
- Confusing React (the library) with React DOM (renders to the browser) or React Native (renders to mobile).
- Assuming you must learn old-style class components first — modern React is written with function components and Hooks.
- Trying to manipulate the DOM directly with document.getElementById inside a component instead of letting React manage it.
Best Practices
- Start with function components and Hooks — this is the modern, recommended style.
- Keep each component small and focused on a single responsibility.
- Think of every component as "data in, UI out."
- Read the messages in the browser console carefully — React's warnings are usually very descriptive.
- Use the official docs at react.dev as your primary reference while learning.
Frequently Asked Questions
Is React a programming language?
No. React is a JavaScript library. You still write JavaScript — React just gives you tools and conventions for building UIs with it.
Do I need to know JavaScript before learning React?
Yes. Solid fundamentals in variables, functions, arrays, objects, and ES6+ features (like arrow functions and destructuring) will make learning React much smoother.
Is React the same as React Native?
No, but they are related. React targets web browsers via React DOM; React Native uses the same component model to build native mobile apps.
Is React still relevant with so many new frameworks?
Yes. React remains one of the most used and actively developed UI libraries in the industry, and it continues to gain new capabilities like concurrent rendering.
What is the difference between React and a framework like Angular?
React is a focused library for the view layer, so you pick complementary tools yourself. Angular is a more complete, opinionated framework that bundles routing, forms, and HTTP handling out of the box.
Key Takeaways
- React is a JavaScript library for building user interfaces out of components.
- It uses a declarative style: you describe the UI for the current state, and React updates the DOM.
- The Virtual DOM lets React update only what actually changed, keeping apps fast.
- Component-based architecture makes UIs reusable, isolated, and easier to maintain.
- React powers everything from social apps to mobile apps (React Native) to full-stack frameworks (Next.js).
Summary
React gives you a declarative, component-based way to build user interfaces, backed by a Virtual DOM that keeps updates fast even as an application grows. Rather than manually tracking every DOM change, you describe what the UI should look like, and React handles the rest.
In this lesson, you learned what React is, how it differs from imperative DOM manipulation, why the Virtual DOM matters, and where React is used in the real world. Next, you will dig into the history behind React and the exact problems it was built to solve.
- You understand what React is and why it exists.
- You can explain declarative vs imperative UI updates.
- You know what the Virtual DOM does and why it is fast.
- You are ready to explore the history behind React.