Skip to main content
React Basics
Prepared By:-
Kale J. N.
Assistant Professor,
Computer Engineering Department,
Sanjivani COE Kopargaon.
Prepared By: Kale J. N.
React is a JavaScript library for building
user interfaces, developed by Facebook
(now Meta).
1. Component-based architecture
2. Declarative syntax (UI updates
automatically with data changes)
3. Used for building Single Page
Applications (SPAs)
4. Open-source and widely supported
Introduction
Prepared By: Kale J. N.
Why Use React?
Main Advantages:
Fast Rendering – Uses Virtual DOM for efficient UI updates.
Reusable Components – Build modular, maintainable code.
One-Way Data Flow – Makes debugging easier and predictable.
Strong Community Support – Large ecosystem of tools and
libraries.
Cross-Platform Development – React Native for mobile apps.
Prepared By: Kale J. N.
• Companies Using React:
• Facebook
• Instagram
• Netflix
• Airbnb
• Uber Eats
• Use Cases:
• Dashboards
• Dynamic Websites
• Single Page Applications (SPAs)
• Progressive Web Apps
Real-World Usage
Prepared By: Kale J. N.
Using Vite (Faster)
1. npm create vite@latest my-react-app
2. cd my-react-app
3. npm install
4. npm run dev
Why Vite?
Extremely fast dev server start and hot module replacement (HMR)
Lightweight, opinionated defaults for modern JS & frameworks
Minimal config to get production-ready builds
Works well with React, TypeScript, CSS modules, PostCSS, etc.
Setting Up a React Project
Prepared By: Kale J. N.
React Project Structure
my-react-app/
┣ src/
┃ ┣ components/
┃ ┣ App.jsx
┃ ┣ main.jsx
┣ public/
┣ package.json
┣ vite.config.js
src/ – main React code
components/ – reusable UI components
App.jsx – root component
main.jsx – entry file connecting React to the DOM
Prepared By: Kale J. N.
What are Components?
Definition:
Components are independent, reusable pieces of UI.
Think of them as functions that return HTML.
Types:
Function Components (modern approach)
Class Components (older approach)
function Welcome() {
return <h1>Hello, React!</h1>;
}
Prepared By: Kale J. N.
Component Hierarchy
App
├── Header
├── MainContent
│ ├── Card
│ ├── Card
└── Footer
Components can contain other components (nested structure).
The App component is usually the root of the tree.
Prepared By: Kale J. N.
Using a Component
function Greeting(props) {
return <h2>Hello, {props.name}!</h2>;
}
function App() {
return (
<div>
<Greeting name="Jaydeep" />
<Greeting name="Kale" />
</div>
);
}
Prepared By: Kale J. N.
Summary
React is a powerful library for building dynamic UIs
Uses components for modular design
Supports fast rendering with Virtual DOM
You can start with Vite or Create React App
Prepared By: Kale J. N.