What it is
UI library
Declarative components, JSX, and efficient DOM updates.

This page is a self-contained introduction to React—a JavaScript library for building interactive user interfaces. You will understand what React is, how components and JSX work, and why teams choose React for modern front-end apps.
UI library
Declarative components, JSX, and efficient DOM updates.
Reusable UI
Functions that return JSX—compose pages from small pieces.
Vite & CDN
Create a Vite project or load React 18 from a CDN.
useState
Props pass data in; state tracks what changes over time.
5 labs
Hello React, components, props, counters, and lists.
Hooks & apps
Practice useEffect, forms, routing, and small projects.
React is a declarative, efficient, and flexible front-end JavaScript library for creating user interfaces using UI components. Instead of manually updating the DOM every time data changes, you describe what the UI should look like—React figures out the minimal updates needed.
React powers single-page applications, dashboards, mobile apps (via React Native), and static sites. Companies such as Meta, Netflix, Airbnb, and Discord use React in production.
React really shines when your data changes over time. Build UIs from reusable components, describe markup with JSX, and let React update the DOM efficiently through its virtual DOM.
Break UIs into small, reusable, testable pieces.
Describe the screen for each state—not every DOM step.
Diff in memory, patch only what changed in the browser.
Next.js, React Router, TanStack Query, and React Native.
In short: React is a view-layer library—compose components, pass props, manage state with hooks, and let React reconcile the DOM.
React components are small, isolated pieces of code that help you compose complex UIs from simple building blocks. A component is usually a JavaScript function that returns JSX describing what to render.
Build a Button once, reuse it anywhere. Nest components: App → Header → NavItem.
function Button({ label }) {
return <button type="button">{label}</button>;
}
// Reuse anywhere:
// <Button label="Save" />
// <Button label="Cancel" /> Learn JavaScript fundamentals first. React builds on functions, objects, and arrays—you will use all three inside every component.
React is a free and open-source front-end JavaScript library developed by Meta and the open-source community under the MIT License.
Jordan Walke is recognized as the original author. React was first deployed on Facebook’s news feed in 2011 and open-sourced at JSConf US in 2013.
| Detail | Value |
|---|---|
| Developer(s) | Meta and community |
| License | MIT License |
| Original author | Jordan Walke |
| Platform | Web (browser); React Native for mobile |
| First release | 2013 (open source) |
| Written in | JavaScript |
JSX (JavaScript XML) lets you write HTML-like tags inside JavaScript. Build tools transform JSX into React.createElement calls.
const element = <h1>Hello, {name}!</h1>;
// JSX compiles to:
// React.createElement('h1', null, 'Hello, ', name, '!'); | JSX rule | Example |
|---|---|
| Embed expressions | {expression} inside tags |
| One parent | Wrap siblings in <div> or <>fragment</> |
| CSS classes | className="card" not class |
| Self-close tags | <img />, <br /> |
The browser DOM is slow to change when you touch many nodes. React keeps a lightweight virtual DOM tree in memory—a JavaScript representation of your UI.
When state or props change, React builds a new virtual tree, compares (diffs) it with the previous one, and updates only the real DOM nodes that actually changed.
For real apps, use a build tool. Vite is fast and widely used in 2026:
npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev For quick experiments without installing Node.js, load React from a CDN:
<div id="root"></div>
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<h1>Hello, React!</h1>);
</script> | Concept | What it does |
|---|---|
| Components | Functions or classes that return UI |
| JSX | Markup syntax inside JavaScript |
| Props | Read-only inputs passed from parent to child |
| State | Data that changes over time (useState, useReducer) |
| Hooks | Functions like useEffect for side effects in function components |
| Virtual DOM | In-memory UI tree for efficient updates |
| Event handling | onClick, onChange with camelCase props |
| Task | Example |
|---|---|
| Render app | root.render(<App />); |
| Component | function Card() { return <div />; } |
| Props | <Welcome name="Alex" /> |
| State | const [n, setN] = useState(0); |
| List render | {items.map(i => <li key={i.id}>{i.text}</li>)} |
| Effect | useEffect(() => { ... }, []); |
Same UI tasks—different mental models.
setCount(n + 1)React: change state; component re-renders automatically
<Button />React: one component, many instances with different props
items.map(...)React: declarative JSX; vanilla JS needs manual DOM loops
Pick React when the UI is interactive, stateful, and expected to grow.
Forms, feeds, dashboards, and live apps where state drives the UI.
Design systems, shared buttons, cards, and layout shells.
Large codebases where component boundaries keep features isolated.
Static marketing pages with little interactivity may not need React at all.
Key benefit: React is a library focused on the view layer—you add routing, data, and tooling as your app grows.
Five starter demos. Use View Output to preview here, or open Try It Yourself to edit and run React in the browser editor (CDN + Babel).
Mount React to a DOM node and render your first JSX heading.
<div id="root"></div>
<script type="text/babel">
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<h1>Hello, React!</h1>);
</script> ReactDOM.createRoot attaches React to a DOM node. root.render puts JSX on screen—React creates the real <h1> for you.
A component is a function that returns a JSX tree.
function Greeting() {
return (
<div>
<h1>Welcome to React</h1>
<p>Components are reusable pieces of UI.</p>
</div>
);
}
root.render(<Greeting />); Greeting is a function component. Calling <Greeting /> runs the function and renders the returned JSX tree.
Pass data from a parent into a child component.
function Welcome({ name }) {
return <h1>Hello, {name}!</h1>;
}
function App() {
return (
<div>
<Welcome name="Alex" />
<Welcome name="Sam" />
</div>
);
} Props are read-only inputs. name="Alex" becomes props.name inside Welcome, so one component renders many greetings.
State lets a component remember and update values over time.
const { useState } = React;
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button type="button" onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
);
} useState(0) returns the current count and a setter. Clicking the button calls setCount, state updates, and React re-renders the component with the new number.
Map an array to JSX list items with a stable key.
function TodoList() {
const tasks = ['Learn JSX', 'Build a component', 'Add state'];
return (
<ul>
{tasks.map((task) => (
<li key={task}>{task}</li>
))}
</ul>
);
} tasks.map turns each string into a <li>. The key prop helps React track list items efficiently when the array changes.
Where React earns a place in modern front-end development.
Dashboards, admin panels, and client-heavy web apps.
Example: analytics or CRM UI.
Multi-step wizards, validation, and live field feedback.
Example: checkout or signup flows.
Social timelines, chat, notifications, and real-time charts.
Example: messaging sidebar widget.
Shared buttons, cards, and layout primitives across products.
Example: company component library.
Reuse component thinking for iOS and Android mobile apps.
Example: cross-platform product app.
Add React to one widget or page inside an existing site.
Example: embed a React search bar.
Why teams choose React for production UIs.
Break interfaces into reusable, testable pieces.
Describe UI per state; React handles DOM diffing.
Next.js, React Router, TanStack Query, and UI libraries.
One of the most requested front-end skills worldwide.
Small habits that keep React code predictable.
Functions, arrays, objects, and destructuring appear in every component.
Use the CDN for quick demos; use Vite when you need modules and production builds.
Inspect component trees, props, and state while you debug.
Mistakes that commonly trip up new React developers.
Changing count++ without setCount skips a re-render.
→ Always use the setter from useState.
React warns when list items lack stable key props.
→ Prefer unique IDs over array index when order can change.
Routing, data fetching, and global state need companion libraries.
→ Plan for Vite, React Router, or Next.js as the app grows.
Global stores before you need them add complexity fast.
→ Lift state up gradually; start with local useState.
User clicks a button, or fetch loads new JSON into state.
React calls your component functions with new props/state.
React compares the new tree with the previous one.
Only changed nodes update on screen—fast, interactive UI.
useState and useEffect over class components.Quick Takeaway: Compose components, pass props, manage state with hooks, and let React reconcile the DOM when data changes.
React runs in modern browsers after you load the library or bundle your app. These tutorials use React 18 with Vite or CDN setups. Logos use the shared browser-image-sprite.png sprite from this project.
Load React and ReactDOM, mount with createRoot, and render components. Production builds target evergreen browsers via your bundler.
Bottom line: Use Vite or a similar bundler for production apps. CDN + Babel is fine for learning demos on this site.
React is a declarative JavaScript library for building user interfaces with reusable components. Describe what the screen should look like for a given state, and React efficiently updates the browser through its virtual DOM.
Start with the CDN examples on this page, then create a Vite project when you are ready to build a real app. Practice props, useState, and list rendering before moving on to routing and data fetching.
Learn JavaScript fundamentals first—React builds on functions, objects, and arrays every day.
key when rendering listskey when list order changesYour gateway to components, JSX, props, state, and hooks.
View layer only—not a full framework
BasicsMarkup inside JavaScript
SyntaxRead-only parent → child data
Data inuseState for changing data
Diff in memory, patch the browser
RuntimeReact really shines when your data changes over time. Build UIs from reusable components, describe markup with JSX, and let React update the DOM efficiently through its virtual DOM. React Native brings the same component model to mobile apps used by Meta, Microsoft, and many startups.
Run the first example in the live editor, then explore props and useState.
11 people found this page helpful