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?

ReasonBenefit
Fast PerformanceUses Virtual DOM
Reusable ComponentsWrite once use many times
Easy UI DesignSimple frontend development
SPA SupportNo page reload
Large CommunityEasy learning and support

React.js Features

FeatureDescription
Component BasedSmall reusable parts
Virtual DOMFast page update
JSXHTML inside JavaScript
One Way Data FlowEasy data handling
HooksManage state and lifecycle
RoutingMultiple pages support

Important React Concepts

ConceptMeaning
ComponentReusable UI block
PropsPass data between components
StateStore dynamic data
HooksSpecial React functions
JSXHTML-like syntax
Event HandlingHandle button click etc.

Types of Components:

TypeDescription
Functional ComponentModern and simple
Class ComponentOld React component

Common Hooks:

HookUse
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-app

cd my-app

Install Packages:

npm install

Run React Project:

npm run dev

http://localhost:5173/

Important Commands:

CommandUse
npm create vite@latest my-appCreate project
cd my-appOpen project folder
npm installInstall packages
npm run devRun project
npm run buildCreate production build