React is a JavaScript library used to create fast and interactive websites and web applications.
- React.js is a JavaScript library
- Used to create UI (User Interface)
- Mainly used for web applications
- Created by Meta
- Fast and reusable frontend library
Why Use React.js?
| Reason | Benefit |
| Fast Performance | Uses Virtual DOM |
| Reusable Components | Write once use many times |
| Easy UI Design | Simple frontend development |
| SPA Support | No page reload |
| Large Community | Easy learning and support |
React.js Features
| Feature | Description |
| Component Based | Small reusable parts |
| Virtual DOM | Fast page update |
| JSX | HTML inside JavaScript |
| One Way Data Flow | Easy data handling |
| Hooks | Manage state and lifecycle |
| Routing | Multiple pages support |
Important React Concepts
| Concept | Meaning |
| Component | Reusable UI block |
| Props | Pass data between components |
| State | Store dynamic data |
| Hooks | Special React functions |
| JSX | HTML-like syntax |
| Event Handling | Handle button click etc. |
Types of Components:
| Type | Description |
| Functional Component | Modern and simple |
| Class Component | Old React component |
Common Hooks:
| Hook | Use |
| useState() | Store data |
| useEffect() | Run code automatically |
| useRef() | Access HTML elements |
| useContext() | Global data sharing |
Create React Project Using Vite:
npm create vite@latest my-appcd my-app
Install Packages:
npm installRun React Project:
npm run devhttp://localhost:5173/
Important Commands:
| Command | Use |
| npm create vite@latest my-app | Create project |
| cd my-app | Open project folder |
| npm install | Install packages |
| npm run dev | Run project |
| npm run build | Create production build |