What is React?
React is a JavaScript library for building user interfaces from components.
A component describes what a part of the interface should look like for its current inputs. When relevant data changes, React can render the component tree again and coordinate the browser updates needed to keep the visible interface in sync.
That sounds simple, but it introduces the mental model used throughout this handbook:
Why does React exist?β
Interactive applications have many pieces of UI that depend on changing data.
Imagine a shopping basket. When a user adds an item, the application might need to update:
- the basket count in the header;
- the basket list;
- the subtotal;
- the checkout button state;
- an empty-state message;
- shipping eligibility;
- related accessibility text.
With direct DOM manipulation, you can build all of this, but you must carefully keep application data and every affected DOM node synchronized yourself.
React gives you another model:
Instead of making every DOM update the center of your application logic, you describe the UI for the current data.
Declarative vs imperative UIβ
An imperative approach says how to update individual browser elements:
const button = document.querySelector('#checkout');
const message = document.querySelector('#message');
if (items.length === 0) {
button.disabled = true;
message.textContent = 'Your basket is empty';
} else {
button.disabled = false;
message.textContent = `${items.length} items`;
}
A React component describes the desired result:
function BasketSummary({items}) {
const isEmpty = items.length === 0;
return (
<section>
<p>{isEmpty ? 'Your basket is empty' : `${items.length} items`}</p>
<button disabled={isEmpty}>Checkout</button>
</section>
);
}
The shift is:
βFind this element and change it.β
βFor this data, the UI should look like this.β
Declarative does not mean React eliminates complexity. It changes where you express that complexity: state, component boundaries, data flow, and render logic become the main design concerns.
Componentsβ
React applications are composed from components.
function Avatar({name, imageUrl}) {
return <img src={imageUrl} alt={name} />;
}
Components can render other components:
function UserCard({user}) {
return (
<article>
<Avatar name={user.name} imageUrl={user.imageUrl} />
<h2>{user.name}</h2>
</article>
);
}
This forms a component tree:
Thinking in component trees is one of the most important React skills because data ownership, state preservation, Context, rendering, and architecture all depend on the tree.
UI as a function of dataβ
A useful conceptual model is:
function Greeting({isLoggedIn, name}) {
if (!isLoggedIn) {
return <p>Please sign in.</p>;
}
return <p>Welcome back, {name}.</p>;
}
React becomes easier to reason about when components are treated as calculations of UI rather than imperative scripts that mutate the page.
React does not continuously watch variablesβ
A common beginner misunderstanding is that React watches every JavaScript variable and automatically updates the page when a variable changes.
It does not.
function Counter() {
let count = 0;
function increment() {
count += 1;
}
return <button onClick={increment}>{count}</button>;
}
Changing count does not tell React that a new render is required.
Later you will use state:
const [count, setCount] = useState(0);
A state update can schedule React rendering work. Each render then receives its own state snapshot.
What does "render" mean?β
Do not define rendering as "React changes the DOM."
A better simplified sequence is:
A component can render without causing a visible DOM change.
That distinction becomes essential for performance and debugging.
React vs the browser DOMβ
React does not replace the browser.
Your application still uses real platform features:
- HTML semantics;
- CSS;
- browser events;
- forms;
- focus;
- URLs;
- network requests;
- accessibility APIs;
- the DOM.
React provides a programming model for describing and coordinating UI on top of the platform.
Senior React engineering requires knowing both React and the web platform underneath it.
React vs a frameworkβ
React itself focuses on UI and rendering primitives.
A complete application often needs decisions about:
- routing;
- data loading and caching;
- server rendering;
- authentication;
- deployment;
- bundling;
- code splitting;
- Server Components infrastructure;
- application conventions.
Frameworks can provide integrated solutions for those concerns.
This handbook distinguishes React core from framework behavior so you know which assumptions are portable.
React core vs ecosystem librariesβ
Libraries such as React Router, TanStack Query, Redux Toolkit, Zustand, and React Hook Form can be useful, but they are not built-in React APIs.
Learn the underlying problem first:
The same principle applies to data fetching, forms, and routing.
Modern React vs legacy Reactβ
This handbook uses modern React 19.2 as its stable documentation target.
New code is taught with:
- function components;
- Hooks;
createRoot;- current Context patterns;
- modern form and Action APIs where appropriate;
- current ref guidance;
- Suspense/transitions/concurrency concepts;
- React Compiler awareness.
Class components, old lifecycle methods, old Context, ReactDOM.render, and similar APIs are still useful when maintaining existing systems, but they belong in the legacy/migration section rather than the beginner path.
See React Version Covered for the exact verified version and release policy.
What React does wellβ
React is a strong fit when an interface has meaningful interaction and benefits from:
- reusable component boundaries;
- state-driven UI;
- composition;
- predictable one-way data flow;
- a large ecosystem;
- client, server, and hybrid rendering options through surrounding tooling/frameworks.
Examples include dashboards, commerce interfaces, SaaS applications, collaborative tools, content products, and rich account experiences.
When React may be unnecessaryβ
A tiny static page does not automatically need React.
If the page is mostly content with little interactive state, plain HTML/CSS/JavaScript or a simpler rendering approach may be enough.
Choosing React is an engineering decision, not proof that an application is "modern."
Common mistakesβ
Thinking React is HTML inside JavaScriptβ
JSX resembles markup, but React's core model is components calculating UI from data. JSX is one syntax used to describe those elements.
Thinking state is a normal mutable variableβ
React state behaves as a render snapshot. Mutating a value is not equivalent to scheduling a React update.
Treating every ecosystem library as part of Reactβ
Know whether a behavior comes from React, React DOM, the browser, a framework, or a third-party library.
Learning APIs before renderingβ
If useEffect, useMemo, or Context feels magical, return to rendering, snapshots, identity, and ownership.
Debugging mindsetβ
When UI is wrong, ask in this order:
This produces better debugging than randomly adding Hooks.
Exerciseβ
Take a familiar interfaceβGitHub, an e-commerce store, or a dashboardβand sketch its component tree.
For example:
Ask:
- Which parts repeat?
- Which components receive data?
- Which values can change?
- Which component should own changing state?
- Which parts are React concerns and which are browser/application concerns?
Interview questionsβ
Juniorβ
What problem does React's declarative model solve compared with manually updating many DOM nodes?
Mid-levelβ
Does a component render always cause a DOM update? Explain the difference.
Seniorβ
What belongs to React core versus a React framework, and why does that distinction matter for architecture?
Summaryβ
Referencesβ
- https://react.dev/
- https://react.dev/learn/describing-the-ui
- https://react.dev/learn/reacting-to-input-with-state
- https://react.dev/learn/render-and-commit
- https://react.dev/reference/rules/components-and-hooks-must-be-pure
Nextβ
Create a modern learning project with Set Up React with Vite.