React Introduction

Beginner
⏱️ 16 min read
📚 Updated: Jul 2026
🎯 5 Examples
components · JSX · hooks

What You’ll Learn

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.

01

What is React

Library overview.

02

Components

Reusable UI.

03

Why React

Key benefits.

04

About React

Meta & MIT.

05

JSX & DOM

Syntax & updates.

06

Examples

Hands-on code.

🤔 What is React?

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.

💡
Beginner tip

Learn JavaScript fundamentals first. React builds on functions, objects, and arrays—you will use all three inside every component.

🧩 What Are React Components?

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.

For example, if you build a Button component once, you can reuse it anywhere in your project to generate a button without rewriting the same markup and styles each time. Nest components inside one another to build pages: AppHeaderNavItem.

App.jsx
function Button({ label }) {
  return <button type="button">{label}</button>;
}

// Reuse anywhere:
// <Button label="Save" />
// <Button label="Cancel" />

🤷 Why React?

Many JavaScript tools exist for front-end work—Angular, Vue, Svelte, jQuery, and plain DOM APIs. So why choose React?

React is a library (not a full framework) focused on the view layer. It promotes reusable UI components that display data that changes over time. When user input or server data updates, React re-renders only what changed—keeping apps fast and predictable.

  • Component model — break UIs into manageable, testable pieces
  • Declarative code — describe the UI for each state, not every DOM step
  • Large ecosystem — routing, state, UI kits, and meta-frameworks like Next.js
  • Strong hiring demand — one of the most requested front-end skills
  • React Native — reuse concepts for iOS and Android mobile apps

📖 About React

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 of React. It was first deployed on Facebook’s news feed in 2011 and open-sourced at JSConf US in 2013. Today React follows semantic versioning with frequent improvements to hooks, server components, and developer tooling.

Table of Content

Have a quick look at React at a glance:

Developer(s)Meta and community
LicenseMIT License
Original authorJordan Walke
PlatformWeb platform (browser); React Native for mobile
First release2013 (open source)
Written inJavaScript

📝 JSX Explained

JSX (JavaScript XML) lets you write HTML-like tags inside JavaScript. It is not required, but almost every React project uses it because it keeps structure readable.

App.jsx
const element = <h1>Hello, {name}!</h1>;

// JSX compiles to:
// React.createElement('h1', null, 'Hello, ', name, '!');
  • Use curly braces {expression} to embed JavaScript values
  • Return one parent element, or use a <>fragment</>
  • Use className instead of class for CSS classes
  • Close all tags—including <img /> and <br />

⚙️ Virtual DOM

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. That batching keeps interfaces responsive even with frequent data updates.

🏁 Getting Started with React

Create a project with Vite (recommended)

For real apps, use a build tool. Vite is fast and widely used in 2026:

terminal
npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev
Try It Yourself

Try React in the browser (CDN)

For quick experiments without installing Node.js, load React from a CDN:

index.html
<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>
Try It Yourself

👍 Advantages of Using React

The following are some of the most significant advantages of using React in your project:

  1. UI-focused design — React lets you create component-driven, user-interface-centric applications
  2. Easier JavaScript UI code — JSX and components reduce repetitive DOM manipulation
  3. SEO-friendly options — server rendering (Next.js) delivers HTML search engines can crawl
  4. Handles dependencies — one-way data flow makes state changes easier to trace
  5. Excellent developer tools — React DevTools inspect component trees and props
  6. Easy to adopt incrementally — add React to one page or widget in an existing site
  7. Cross-platform — React Native shares concepts for iOS and Android
  8. Strong community — tutorials, libraries, and hiring pool are enormous

👎 Disadvantages and Considerations

React is powerful, but weigh these trade-offs before adopting it everywhere:

  1. Tooling required — JSX and modern syntax need a bundler (Vite, webpack) for production apps
  2. Fast-moving ecosystem — patterns and libraries evolve; staying current takes effort
  3. Not a full framework — you choose routing, data fetching, and state libraries yourself
  4. Bundle size — React adds JavaScript compared to plain HTML pages
  5. Learning curve — hooks, context, and performance patterns take practice

🧰 Core Building Blocks

ConceptWhat it does
ComponentsFunctions or classes that return UI
JSXMarkup syntax inside JavaScript
PropsRead-only inputs passed from parent to child
StateData that changes over time (useState, useReducer)
HooksFunctions like useEffect for side effects in function components
Virtual DOMIn-memory UI tree for efficient updates
Event handlingonClick, onChange with camelCase props

⚡ Quick Reference

TaskExample
Render approot.render(<App />);
Componentfunction Card() { return <div />; }
Props<Welcome name="Alex" />
Stateconst [n, setN] = useState(0);
List render{items.map(i => <li key={i.id}>{i.text}</li>)}
EffectuseEffect(() => { ... }, []);

Examples Gallery

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).

Example 1 — Hello, React!

index.html
<div id="root"></div>
<script type="text/babel">
  const root = ReactDOM.createRoot(document.getElementById('root'));
  root.render(<h1>Hello, React!</h1>);
</script>
Try It Yourself

Example 2 — Function component

App.jsx
function Greeting() {
  return (
    <div>
      <h1>Welcome to React</h1>
      <p>Components are reusable pieces of UI.</p>
    </div>
  );
}

root.render(<Greeting />);
Try It Yourself

Example 3 — Props

App.jsx
function Welcome({ name }) {
  return <h1>Hello, {name}!</h1>;
}

function App() {
  return (
    <div>
      <Welcome name="Alex" />
      <Welcome name="Sam" />
    </div>
  );
}
Try It Yourself

Example 4 — Counter with useState

App.jsx
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>
  );
}
Try It Yourself

Example 5 — Render a list

App.jsx
function TodoList() {
  const tasks = ['Learn JSX', 'Build a component', 'Add state'];

  return (
    <ul>
      {tasks.map((task) => (
        <li key={task}>{task}</li>
      ))}
    </ul>
  );
}
Try It Yourself

📋 React vs Vanilla JavaScript

TaskReactVanilla JS
Update textChange state; React re-renderselement.textContent = '...'
Reusable UI<Button /> componentCopy HTML or template strings
List of itemsitems.map(...) in JSXLoop + createElement or innerHTML
Complex appsComponent tree + hooksManual DOM sync gets fragile

🧠 How React Updates the UI

1

Event or data change

User clicks a button, or fetch loads new JSON into state.

Trigger
2

Re-render components

React calls your component functions with new props/state.

Render
3

Diff virtual DOM

React compares the new tree with the previous one.

Reconcile
=

DOM patch applied

Only changed nodes update on screen—fast, interactive UI.

📚 Why Learn React?

  • Industry standard — thousands of companies hire React developers
  • Component thinking — skills transfer to Vue, Svelte, and design systems
  • Rich ecosystem — Next.js, React Router, TanStack Query, and UI libraries
  • Mobile path — React Native uses the same mental model
  • Portfolio projects — build todo apps, dashboards, and SPAs employers recognize

Summary

  • React is a declarative JavaScript library for building user interfaces with components.
  • Components are reusable functions that return JSX; props pass data in, state tracks changes.
  • React uses a virtual DOM to update the browser efficiently when data changes.
  • Created by Jordan Walke at Meta; open source under the MIT License.
  • Start with Vite for projects, or the CDN for quick browser experiments.
  • React really shines when your data changes over time—forms, feeds, dashboards, and live apps.

💡 Best Practices

✅ Do

  • Keep components small and focused on one job
  • Use meaningful prop and state names
  • Add key when rendering lists
  • Install React DevTools in your browser
  • Prefer function components and hooks in new code
  • Lift shared state up to the nearest common parent

❌ Don’t

  • Mutate state directly—use setter functions
  • Skip learning JavaScript before React
  • Put fetch logic everywhere without a clear pattern
  • Use array index as key when list order changes
  • Over-engineer global state on day one
  • Ignore accessibility (labels, buttons, semantic HTML)

❓ Frequently Asked Questions

React is a declarative JavaScript library for building user interfaces. You compose UIs from reusable components, describe what the screen should look like for a given state, and React efficiently updates the browser when data changes.
React is a library focused on the view layer. It handles UI rendering and component logic. Routing, global state, and data fetching are often added with companion libraries like React Router or handled by meta-frameworks such as Next.js.
Yes. React is written in JavaScript (or TypeScript). Learn variables, functions, arrays, objects, and ES6 features like arrow functions and destructuring before diving into components, props, and hooks.
JSX is a syntax extension that lets you write HTML-like markup inside JavaScript. Build tools transform JSX into React.createElement calls. It makes component templates readable and keeps structure close to logic.
Yes. React is open source under the MIT License, maintained by Meta and a large community. You can use it in personal and commercial projects without licensing fees.
Practice props, state with useState, and rendering lists with map. Then learn useEffect, forms, fetching data, React Router, and a build tool like Vite. Build small apps—a todo list, weather widget, or dashboard—to solidify concepts.
Did you know?

React’s influence goes far beyond the web. Ideas pioneered in React—components, declarative UI, and a virtual DOM diff—inspired frameworks like Vue and influenced how browsers and standards evolve. React Native brings the same component model to mobile apps used by Meta, Microsoft, and many startups.

Try It Yourself

Edit any example from this page in the live Try It editor.

Open Try It editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful