Lesson 3 of 60 – Features of React
5%

Features of React

React provides several features that make it useful for building modern, interactive, and maintainable user interfaces. These features include reusable components, JSX, state management, props, event handling, Hooks, conditional rendering, and more.

Note: React is designed around a component-based approach. Understanding its main features will help you understand how React applications are structured and developed.

1. Component-Based Architecture

React applications are commonly divided into small and reusable components. Each component can represent a particular part of the user interface.

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

2. Reusable Components

React components can be reused in different parts of an application. This reduces unnecessary duplication of UI code.

Button Component
       ↓
Login Page
       ↓
Registration Page
       ↓
Contact Page

3. JSX

JSX allows developers to write HTML-like markup inside JavaScript code.

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

JSX makes the structure of a component's user interface easier to read and write.

4. Declarative UI

React uses a declarative approach to describing user interfaces. You describe what the UI should look like for a particular state, and React handles updating the interface.

State
  ↓
React
  ↓
Desired UI

5. State Management

React provides mechanisms for managing changing data inside components.

State
  ↓
User Action
  ↓
State Update
  ↓
UI Update

The useState Hook is commonly used for managing local component state.

6. Props

Props allow data to be passed from a parent component to a child component.

<Student
    name="Amit"
    course="React"
/>

Props help make components flexible and reusable.

7. Event Handling

React allows components to respond to user events such as clicks, keyboard input, form submission, and other interactions.

function App() {

    function handleClick() {
        alert("Button clicked!");
    }

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

8. Conditional Rendering

React allows different UI elements to be displayed depending on conditions.

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

This is useful when an application needs to show different content for different states.

9. Rendering Lists

React can render collections of data such as products, students, or courses.

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

courses.map(course => (
    <li>{course}</li>
));

10. Keys in Lists

When rendering lists, React uses keys to identify individual elements in the list.

{courses.map(course => (
    <li key={course}>
        {course}
    </li>
))}

Keys help React identify which list items have changed.

11. React Hooks

Hooks allow functional components to use React features such as state and side effects.

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

12. useState Hook

The useState Hook allows a component to store and update local state.

import { useState } from "react";

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

Calling the setter updates the state and causes the component to render with the new state.

13. useEffect Hook

The useEffect Hook is commonly used for side effects such as fetching data or interacting with external systems.

useEffect(() => {
    console.log("Effect executed");
}, []);

14. Component Composition

React encourages composing applications from smaller components. One component can contain or use other components.

App
 |
 +-- Header
 +-- Main
 |    |
 |    +-- ProductList
 |         |
 |         +-- Product
 |
 +-- Footer

15. One-Way Data Flow

React commonly follows a one-way data flow where data moves from parent components to child components through props.

Parent
  ↓
Props
  ↓
Child
  ↓
Child UI

16. Virtual DOM Concept

React uses a virtual representation of the UI to determine changes that need to be reflected in the browser DOM.

State Change
     ↓
React
     ↓
Virtual UI Comparison
     ↓
Required DOM Updates

This approach helps React manage UI updates efficiently.

17. Efficient UI Updates

React determines which parts of the interface need to be updated when relevant data changes instead of requiring developers to manually update every affected DOM element.

Data Changes
     ↓
React
     ↓
Identify UI Changes
     ↓
Update Interface

18. Forms and User Input

React can manage form fields and user input through component state and event handlers.

Input
  ↓
onChange
  ↓
State
  ↓
Updated Input

This approach is commonly used for login, registration, search, and other forms.

19. API Integration

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

React
  ↓
HTTP Request
  ↓
API
  ↓
Database
  ↓
JSON Response
  ↓
React

20. React Router

React applications can use routing libraries such as React Router to organize navigation between different URLs and views.

/home
/about
/courses
/contact

21. Single-Page Applications

React is commonly used to build single-page applications where the browser can update the displayed interface dynamically as users navigate and interact with the application.

Browser
   ↓
React App
   ↓
Components
   ↓
Dynamic Interface

22. Custom Hooks

Developers can create custom Hooks to reuse stateful logic between components.

function useCounter() {
    // reusable logic
}

Custom Hooks normally start with the word use.

23. Context API

React provides Context for making values available to components without passing props through every intermediate component.

Provider
    ↓
Context
    ↓
Child Component
    ↓
Nested Component

It can be useful for values such as themes, authentication state, or other shared application data.

24. Developer Tools

React Developer Tools can help developers inspect components and debug React applications during development.

  • Inspect components
  • View component hierarchy
  • Inspect props
  • Inspect state
  • Debug application structure

25. Open Source

React is open-source software. Developers can use it, study its source, and participate in its ecosystem.

Open Source
     ↓
React
     ↓
Developers
     ↓
Applications

26. Large Ecosystem

React is supported by a large ecosystem of libraries, tools, and development resources.

  • Routing libraries
  • UI component libraries
  • Form libraries
  • State management tools
  • Testing tools
  • Build and development tools

27. Cross-Platform Development

React concepts can also be used beyond traditional web interfaces. For example, React Native uses React concepts for building native mobile applications.

React Concepts
      ↓
Components
Props
State
Hooks
      ↓
Web / Other React-Based Platforms

28. Developer Productivity

Reusable components, JSX, Hooks, development tools, and a large ecosystem can help developers organize and maintain applications.

Reusable Components
        +
Hooks
        +
Tools
        +
Libraries
        ↓
Organized Development

29. Maintainable Application Structure

Breaking a large interface into smaller components can make an application easier to understand and maintain.

Large Application
       ↓
Small Components
       ↓
Reusable Logic
       ↓
Easier Maintenance

30. Summary of React Features

React provides a component-based approach for building interactive user interfaces. Its major features work together to make modern application development more structured.

React
 |
 +-- Components
 +-- JSX
 +-- Props
 +-- State
 +-- Hooks
 +-- Events
 +-- Conditional Rendering
 +-- Lists
 +-- API Integration
 +-- Routing
 +-- Context
 +-- Developer Tools

Understanding these features provides a strong foundation for learning React in greater depth.

📌 Key Points

  • React uses a component-based architecture.
  • Components can be reused throughout an application.
  • JSX provides an HTML-like syntax for describing UI.
  • React follows a declarative approach to UI development.
  • Props allow data to move from parent components to child components.
  • State represents changing data in components.
  • Hooks provide React features to functional components.
  • React supports event handling and interactive forms.
  • React can conditionally render content and display lists.
  • React applications can communicate with APIs.
  • React Router can be used for navigation.
  • Context can provide shared values to components.
  • Custom Hooks allow reusable stateful logic.
  • React has a large ecosystem of tools and libraries.

🧠 Quick Quiz

Question: Which React feature allows developers to build reusable UI parts?