
React.js (or simply React) is an open-source JavaScript library developed by Facebook (Meta) for building user interfaces (UIs) β especially single-page applications (SPAs).
It helps you create reusable UI components that efficiently update and render when your data changes.
π§© Why Use React?
Hereβs why developers love React:
- Component-Based Architecture β Build encapsulated, reusable UI pieces.
- Virtual DOM β Updates only whatβs necessary, improving performance.
- Declarative Syntax β Describe what you want the UI to look like, not how to update it.
- Fast Rendering β Efficient diffing and updating of the DOM.
- Huge Ecosystem β Tons of libraries, tools, and community support.
- Can Be Used Everywhere β Web (React DOM), mobile (React Native), desktop (Electron).
βοΈ Setting Up React
Option 1: Using Create React App
Simplest way to start a new React project.
npx create-react-app my-app
cd my-app
npm start
Option 2: Using Vite (faster modern build tool)
npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev
Folder structure (simplified)
my-react-app/
βββ src/
β βββ App.js
β βββ index.js
β βββ components/
β βββ ...
βββ public/
βββ package.json
π§ Core React Concepts
1. Components
React apps are built from components.
A component is a reusable piece of UI, usually defined as a function or class.
Functional Component (modern way)
function Welcome() {
return <h1>Hello, React!</h1>;
}
Using the Component
function App() {
return (
<div>
<Welcome />
<p>Welcome to React Basics.</p>
</div>
);
}
export default App;
2. JSX (JavaScript XML)
React uses JSX, which lets you write HTML-like code inside JavaScript.
const element = <h1>Hello, JSX!</h1>;
JSX is not HTML β itβs syntactic sugar that compiles to JavaScript.
3. Props (Properties)
Props are like function arguments β they allow you to pass data into components.
function Greeting(props) {
return <h2>Hello, {props.name}!</h2>;
}
// Usage
<Greeting name="Raj" />
4. State
State is used to store and manage data that can change over time.
React re-renders components automatically when state updates.
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increase</button>
</div>
);
}
5. Event Handling
React handles events using camelCase syntax and function references.
function ClickButton() {
function handleClick() {
alert("Button clicked!");
}
return <button onClick={handleClick}>Click Me</button>;
}
6. Conditional Rendering
Render elements conditionally using JavaScript logic.
function UserStatus({ loggedIn }) {
return (
<div>{loggedIn ? <h2>Welcome Back!</h2> : <h2>Please Log In</h2>}</div>
);
}
7. Lists and Keys
Render lists using .map() and unique keys.
const fruits = ["Apple", "Banana", "Cherry"];
function FruitList() {
return (
<ul>
{fruits.map((fruit, index) => (
<li key={index}>{fruit}</li>
))}
</ul>
);
}
8. Hooks (introduced in React 16.8)
Hooks allow you to use state and lifecycle features in functional components.
Common hooks:
useState()β Manage component stateuseEffect()β Run side effects (like fetching data)useContext()β Share data between components without props
Example with useEffect:
import { useState, useEffect } from "react";
function Timer() {
const [seconds, setSeconds] = useState(0);
useEffect(() => {
const timer = setInterval(() => setSeconds(s => s + 1), 1000);
return () => clearInterval(timer); // cleanup
}, []);
return <p>Time: {seconds}s</p>;
}
9. React DOM Rendering
React applications are typically rendered into a root DOM node.
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
π§± React Architecture Overview
React application structure:
index.js β main entry point
App.js β main component
components/ β reusable UI parts
Data flow is unidirectional:
Parent β Child via props.
π Summary Table
| Concept | Description |
|---|---|
| Library Type | UI library (not a full framework) |
| Created By | Facebook (Meta) |
| Language | JavaScript (with JSX) |
| Architecture | Component-based |
| Rendering | Virtual DOM |
| File Extension | .js or .jsx |
| Common Tools | Vite, Create React App, Next.js |

Iβve been struggling with this topic for a while, and this tutorial finally made it click for me. Great job!
Acknowledge their effort: Mentioning their hard work shows you recognize the dedication that went into creating the notes.