by umidjon gafforov
02 min read
May 08, 2025
Share
React is a JavaScript library developed and maintained by Facebook, designed for building user interfaces. It simplifies UI development through a component-based approach. With React, you can build large applications by breaking them down into simple, reusable parts called components.
Component-based Architecture
Each part of the UI — such as buttons, forms, and modals — is written as a separate component.
JSX (JavaScript XML)
React allows writing components using HTML-like syntax within JavaScript.
Virtual DOM
React updates only the parts of the DOM that have changed, making it fast and efficient.
One-way Data Binding
Data flows from parent to child components, which makes the code easier to control and debug.
Hooks
Hooks allow you to use features like state (useState
) and side effects (useEffect
) in functional components.
To create a project:
npx create-react-app my-app
cd my-app
npm start
import React from "react";
function Welcome(props) {
return <h1>Hello, {props.name}!</h1>;
}
useState
Hookimport React, { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<h2>Count: {count}</h2>
<button onClick={() => setCount(count + 1)}>+</button>
<button onClick={() => setCount(count - 1)}>-</button>
</div>
);
}
✅ This component updates the count
state when the user clicks the buttons.
useEffect
Hookimport React, { useEffect, useState } from "react";
function Timer() {
const [seconds, setSeconds] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setSeconds((prev) => prev + 1);
}, 1000);
return () => clearInterval(interval); // cleanup
}, []);
return <h3>Time: {seconds} seconds</h3>;
}
✅ This component increments the seconds
state every second.
function Card({ title, children }) {
return (
<div style={{ border: "1px solid gray", padding: "1rem" }}>
<h2>{title}</h2>
<div>{children}</div>
</div>
);
}
// Usage:
<Card title="News">
<p>React 19 is coming soon!</p>
</Card>
function LoginForm() {
const [email, setEmail] = useState("");
const handleSubmit = (e) => {
e.preventDefault();
alert("Email: " + email);
};
return (
<form onSubmit={handleSubmit}>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Enter your email"
/>
<button type="submit">Submit</button>
</form>
);
}
Large community and rich ecosystem
Reusable components
Easy to manage large and complex UIs
Foundation for both web and mobile apps (React Native)
React is a powerful and modern library that simplifies the web application development process. Whether you're working on small projects or large enterprise systems, React is a reliable choice. With JSX, components, and hooks, you can keep your code clean and efficient.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
See all posts by this author