What Is React?
Understand React, how it works, why developers use it, and how React components help build interactive web applications.
1. What Is React?
React is an open-source JavaScript library for building user interfaces. It allows developers to divide a webpage into small, reusable components.
A component can represent a navbar, course card, registration form, student profile, or any other part of a user interface. These components can be combined to build a complete application.
For example, a CIIT Training Institute website can use separate components for courses, student enquiries, contact details, and navigation menus.
2. How Does React Work?
This simplified diagram shows how React components use data to describe the user interface.
Components
Define reusable interface sections.
Props and State
Supply component data and changing values.
Rendered UI
React updates the screen when necessary.
3. Understanding Components
Components are the building blocks of a React application. A function component is a JavaScript function that returns React elements, commonly described using JSX.
Navbar Component
Displays navigation links such as Home, Courses, About Us, and Contact.
Course Component
Displays an individual course name, description, duration, and details.
Form Component
Provides input fields for students to submit their enquiries.
Footer Component
Displays contact details, useful links, and other footer information.
4. Practical Example: Create a React Component
Let's create a simple component that displays a welcome message.
Step 1: Create Welcome.jsx
function Welcome() {
return (
<h1>Welcome to CIIT Training Institute!</h1>
);
}
export default Welcome;
Step 2: Use It in App.jsx
import Welcome from "./Welcome";
function App() {
return (
<div>
<Welcome />
</div>
);
}
export default App;
Expected Output
Welcome to CIIT Training Institute!
function Welcome()defines a component.returndescribes the content to display.export defaultexports the component.import Welcomeimports the component into another file.<Welcome />renders the component insideApp.
5. React vs a Traditional HTML Page
| Traditional HTML and JavaScript | React |
|---|---|
| Developers can update DOM elements directly. | Developers describe the UI using components and data. |
| Reusable UI patterns must be organised manually. | Components provide a reusable UI structure. |
| UI updates can involve manually managing DOM changes. | React manages rendering and DOM updates for the UI it controls. |
| Can be a good choice for simple static pages. | Can be useful for interactive, component-based applications. |
6. Where Is React Used?
E-Commerce Websites
Product listings, shopping carts, filters, and checkout interfaces.
Training Portals
Course listings, student dashboards, and enquiry forms.
Admin Dashboards
Data tables, charts, forms, and interactive reports.
Social Applications
Feeds, user profiles, notifications, and interactive controls.
Summary
- React is a JavaScript library for building user interfaces.
- Components divide an interface into reusable parts.
- Props pass data to components.
- State represents changing information in a component.
- JSX provides a convenient syntax for describing UI elements.
- React is used to build interactive web applications.