Features of React
Discover the important features of React, including reusable components, declarative UI, one-way data flow, JSX, Hooks, and efficient UI updates.
1. What Are the Features of React?
React provides features that help developers organise user interfaces, manage changing data, and create reusable UI elements. These features are useful for building applications such as course portals, dashboards, shopping websites, and student management systems.
For example, CIIT Training Institute can create a reusable course card and use the same component to display Java, Python, React, and .NET courses. Only the course information needs to change.
2. Main Features of React
This diagram groups some of React's important features and shows how they contribute to building an application.
Components
Divide the interface into reusable parts.
Props and State
Pass information and manage changing values.
Rendering
Update the displayed interface when needed.
Interactive User Interface
Components work together to create the application screen.
3. Component-Based Architecture
React applications are built from components. Each component can represent a small part of a page, such as a navbar, button, course card, or student profile.
Components can be combined to create larger interfaces. Reusable components reduce duplication and make UI code easier to maintain.
Example: Reusable Course Component
function CourseCard({ name }) {
return (
<div>
<h3>{name}</h3>
<p>Learn with practical examples.</p>
</div>
);
}
function App() {
return (
<div>
<CourseCard name="React" />
<CourseCard name="Python" />
<CourseCard name=".NET" />
</div>
);
}
export default App;
Expected Output
React
Learn with practical examples.
Python
Learn with practical examples.
.NET
Learn with practical examples.
CourseCard component is used three times.
Its name prop changes the course title, while the remaining
structure is reused.
4. Declarative User Interface
React uses a declarative approach. Developers describe what the UI should display for the current data, and React handles rendering the required changes.
For example, we can display a welcome message based on a variable instead of manually changing the text of an HTML element.
Example
function Welcome() {
const studentName = "Rahul";
return (
<h2>Welcome, {studentName}!</h2>
);
}
export default Welcome;
Expected Output
Welcome, Rahul!
5. One-Way Data Flow
In React, data commonly flows from a parent component to a child component through props. A child can notify its parent about an event by calling a function passed as a prop.
Parent Component
Holds data and passes props to the child.
Child Component
Receives props and displays information.
Data usually flows down through props; callbacks can communicate events upward.
Example
function Student({ name }) {
return <p>Student Name: {name}</p>;
}
function App() {
return <Student name="Priya" />;
}
export default App;
Expected Output
Student Name: Priya
"Priya" to the child through the
name prop. The child reads that value and displays it.
6. JSX Support
JSX is a syntax extension that lets developers describe UI elements using markup-like syntax inside JavaScript code. It is commonly used when writing React components.
Example
function Course() {
const courseName = "React";
return (
<section>
<h2>{courseName} Tutorial</h2>
<p>Learn step by step.</p>
</section>
);
}
export default Course;
Expected Output
React Tutorial
Learn step by step.
7. State and Interactive UI
React state stores information that can change while an application is running. When state updates, React can render the component again to show the current value.
Example: Counter
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>
Increase
</button>
</div>
);
}
export default Counter;
Expected Initial Output
Count: 0
This is a static illustration of the initial output. The code example must run inside a React application for the button to work.
useState(0) sets the initial count to zero.
Calling setCount requests a state update, and React
renders the latest count in the interface.
8. React Hooks
Hooks are functions that let function components use React features,
such as state and effects. Common examples include
useState, useEffect, and useRef.
useState
Stores and updates component state.
useEffect
Synchronizes a component with external systems when needed.
useRef
Holds a value between renders without triggering a render when it changes.
9. Efficient UI Updates
React calculates how the rendered UI should change when component inputs or state updates. For web applications, React DOM applies the necessary changes to the browser DOM.
React uses reconciliation to compare its new rendering with the previous one and determine the updates needed. This helps developers describe UI changes without manually coordinating every DOM operation.
Data Changes
State or props change.
Reconciliation
React determines required UI updates.
DOM Updates
The browser interface is updated as needed.
10. React Features at a Glance
| Feature | Purpose | Example |
|---|---|---|
| Components | Divide UI into reusable parts. | CourseCard |
| Declarative UI | Describe the required UI for current data. | Welcome message |
| Props | Pass information into components. | Course name |
| State | Manage changing component information. | Counter value |
| JSX | Describe elements using markup-like syntax. | Heading and paragraph |
| Hooks | Use React features in function components. | useState |
| Reconciliation | Determine how the rendered UI should change. | Updating counter output |
Summary
- React supports reusable, component-based user interfaces.
- Declarative UI describes what should be displayed.
- Props pass data from parent components to child components.
- State manages information that changes over time.
- JSX provides a convenient syntax for describing UI elements.
- Hooks let function components use React features.
- Reconciliation helps React determine the UI updates that are needed.