React Introduction

Beginner
6 min read
Updated: Oct 2026
UI library

What Is React?

React is a declarative JavaScript library for building user interfaces. You compose screens from reusable components, describe markup with JSX, and React updates the DOM when your data changes.

Remember
UI = f(state)

Build from components:
  function App() { return <h1>Hello</h1>; }

Mount:
  ReactDOM.createRoot(root).render(<App />)

React is a library (view layer), not a full framework

Created by Jordan Walke at Meta and released as open source (MIT). Pair it with Vite for apps, or try a CDN demo before installing a toolchain.

Why Use React?

Manual DOM updates get hard as UIs grow. React lets you describe the UI for a given state and handles the rest.

NeedHow React helps
Reusable UI piecesComponents you compose like Lego blocks
Changing dataState updates re-render only what changed
Readable markupJSX keeps structure next to logic
Huge ecosystemRouter, forms, Next.js, and countless libraries

How React Updates the UI

From state change to pixels on screen:

StepWhat happens
1. RenderComponents return JSX that describes the UI
2. Virtual DOMReact builds a lightweight tree of elements
3. DiffOn update, React compares the new tree to the old one
4. CommitOnly the needed real DOM nodes change

Your First React App

Quick CDN demo (no install), or scaffold with Vite for real projects:

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Hello React</title>
</head>
<body>
  <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">
    function App() {
      return <h1>Hello, React!</h1>;
    }

    const root = ReactDOM.createRoot(document.getElementById('root'));
    root.render(<App />);
  </script>
</body>
</html>
Try It Yourself

Vite (recommended for projects)

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

How It Works

1. Component. App is a function that returns JSX.

2. Root. createRoot attaches React to the #root DOM node.

3. Render. root.render(<App />) paints the UI on the page.

React vs Vanilla JavaScript

Same browser, different way to build UI:

ReactVanilla JS
Declarative: describe the UIImperative: mutate DOM nodes by hand
Components + props + stateCustom functions and event listeners
JSX templatesHTML strings or createElement
Virtual DOM diffs updatesYou decide every DOM write

When to use which

Use React when…Prefer vanilla when…
The UI has lots of interactive stateThe page is mostly static
You want reusable component treesYou need zero framework weight
The team ships SPAs or dashboardsA few DOM tweaks are enough

Core Building Blocks

These ideas show up in almost every React app:

ConceptWhat it does
ComponentA function that returns UI (JSX)
JSXHTML-like syntax inside JavaScript
PropsInputs passed from parent to child
StateData that can change and trigger re-renders
HooksAPIs like useState and useEffect
Virtual DOMIn-memory tree React diffs before updating the page

Where Is React Used?

React powers a huge share of modern front ends:

Use caseWhy React fits
Single-page appsComponent trees and client-side routing
DashboardsLots of widgets that update independently
Marketing sitesNext.js and similar for SSR / static pages
Mobile appsReact Native reuses component ideas
Design systemsShared buttons, forms, and layout primitives
Embedded widgetsMount React into part of an existing page

Key Takeaways

  • React is a UI library—components describe the view.
  • JSX + state: describe UI; React updates the DOM.
  • Start with a CDN demo, then Vite for real apps.
  • Learn JS first—React builds on language fundamentals.

One line: React turns state into UI—practice with Hello, React, then explore Node.js for tooling.

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

Try Hello, React!

Open the live editor, then continue with Node.js for a Vite-based workflow.

Open Try It →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

14 people found this page helpful