Lesson 2 of 60 – What is React?
3%

What is React?

React is a JavaScript library used to build interactive and reusable user interfaces. It helps developers create modern web applications by dividing the interface into small, reusable components.

Note: React is mainly concerned with the user interface layer. It works with JavaScript and can be combined with other libraries and tools to build complete web applications.

1. Definition of React

React is an open-source JavaScript library for building user interfaces.

React
  ↓
User Interface
  ↓
Web Application

It is commonly used to create dynamic and interactive interfaces.

2. React is Based on JavaScript

React uses JavaScript as its programming language. JavaScript knowledge helps you understand React concepts more easily.

JavaScript
     ↓
    React
     ↓
Interactive UI

3. React is a Library

React is generally described as a JavaScript library rather than a complete programming language.

A library provides reusable functionality that developers can use in their applications.

JavaScript
     +
React Library
     ↓
Web Application

4. What Does React Do?

React helps developers create the visual interface of an application.

  • Displays data
  • Handles user interaction
  • Updates the interface
  • Creates reusable components
  • Manages component state
  • Works with application data

5. React User Interface

A user interface is the part of an application that users see and interact with.

User
 ↓
Buttons
Forms
Menus
Cards
Tables
 ↓
React UI

6. React Components

React applications are commonly divided into components. Each component can represent a specific part of the interface.

Application
    |
    +-- Header
    +-- Navbar
    +-- Sidebar
    +-- Content
    +-- Footer

7. Component Reusability

A major advantage of components is that the same component can often be reused in different parts of an application.

Button Component
      ↓
Login Page
      ↓
Product Page
      ↓
Contact Page

8. Simple React Component

function Welcome() {
    return <h1>Hello React</h1>;
}

The Welcome function represents a simple React component that returns an interface element.

9. Using a Component

A React component can be used inside another component.

function App() {
    return (
        <div>
            <Welcome />
        </div>
    );
}

10. React and HTML

React uses JSX, which allows developers to write HTML-like markup inside JavaScript.

function App() {
    return <h1>Welcome</h1>;
}

JSX is not exactly HTML. It is a syntax that is transformed into JavaScript for use by React.

11. React and CSS

React does not replace CSS. CSS can still be used to style React applications.

React
  +
CSS
  ↓
Styled User Interface

You can use regular CSS as well as other styling approaches in React projects.

12. React and JavaScript Events

React allows components to respond to user events.

function App() {

    function showMessage() {
        alert("Hello!");
    }

    return (
        <button onClick={showMessage}>
            Click Me
        </button>
    );
}

13. React State

State represents information that can change while a component is being used.

Initial State
     ↓
User Action
     ↓
State Changes
     ↓
UI Updates

React provides Hooks such as useState for managing state in functional components.

14. React Props

Props allow a component to receive data from another component.

<Student name="Rahul" />

The Student component can use the supplied name value.

15. React and Dynamic Data

React can display data that changes during the application's execution.

Data
 ↓
React Component
 ↓
User Interface

When relevant state changes, React can update the interface to reflect the new data.

16. React and Lists

React can render multiple elements from JavaScript arrays.

const courses = [
    "HTML",
    "CSS",
    "JavaScript",
    "React"
];

The map() method is commonly used to convert array data into React elements.

17. Conditional User Interface

React can display different content depending on a condition.

{isLoggedIn
    ? <Dashboard />
    : <Login />
}

This allows an interface to respond to application state.

18. React Hooks

Hooks are functions provided by React that allow functional components to use different React features.

useState()
useEffect()
useRef()
useContext()

19. React useState

The useState Hook allows a functional component to keep track of state.

const [count, setCount] = useState(0);

Here, count stores the current value and setCount updates it.

20. React useEffect

The useEffect Hook is commonly used to perform side effects in functional components.

useEffect(() => {
    console.log("Component loaded");
}, []);

21. React and API Communication

React applications can communicate with backend APIs to retrieve or send data.

React
  ↓
HTTP Request
  ↓
Backend API
  ↓
Database
  ↓
Response
  ↓
React

22. React and JSON Data

APIs often return data in JSON format. React can use that data to display information to users.

{
    "id": 1,
    "name": "Amit",
    "course": "React"
}

23. React Router

React Router can be used to create navigation between different views or routes in a React application.

/home
/about
/contact
/courses

It helps organize navigation in applications with multiple views.

24. React Single-Page Applications

React is commonly used to create single-page applications, where the browser can update the displayed interface without requiring a traditional full-page navigation for every interaction.

Browser
   ↓
React Application
   ↓
Components
   ↓
Dynamic UI

25. React Application Flow

User
 ↓
Event
 ↓
Component
 ↓
State / Props
 ↓
React
 ↓
Updated UI

This basic flow helps explain how React applications respond to user interaction and data changes.

26. React Project Files

A modern React project commonly contains source files and project configuration files.

my-react-app/
│
├── src/
├── public/
├── package.json
└── node_modules/

The exact structure can vary depending on the project setup and tools being used.

27. React and npm

React projects commonly use npm or another JavaScript package manager to install packages and run development commands.

npm install
npm run dev

The available commands depend on the project configuration.

28. Where is React Used?

React can be used to build many types of web interfaces and applications.

  • Business websites
  • Dashboards
  • Admin panels
  • Learning platforms
  • E-commerce interfaces
  • Social applications
  • Booking systems
  • Data-driven applications

29. React Learning Requirements

Before learning React, it is helpful to understand the following JavaScript concepts:

  • Variables
  • Functions
  • Arrays
  • Objects
  • Array methods
  • Conditions
  • Loops
  • Events
  • ES6 features
  • Modules

30. React in Simple Words

In simple words, React provides a component-based way to build interactive user interfaces with JavaScript.

JavaScript
    ↓
React
    ↓
Components
    ↓
Props + State
    ↓
Interactive UI
    ↓
Web Application

Once you understand components, JSX, props, state, events, and Hooks, you can start building useful React applications.

📌 Key Points

  • React is a JavaScript library for building user interfaces.
  • React applications are commonly organized into components.
  • Components can be reused throughout an application.
  • JSX provides an HTML-like syntax for describing UI.
  • Props allow components to receive data.
  • State represents data that can change in a component.
  • Hooks provide React features to functional components.
  • React can handle user events and forms.
  • React can display dynamic and conditional content.
  • React applications can communicate with APIs.
  • React Router can provide client-side navigation.
  • JavaScript knowledge is important for learning React.

🧠 Quick Quiz

Question: What is React mainly used for?