Hackforge Academy

Category: react

Reusable component in react

Published on 09 Apr 2026

Explanation

A reusable component in React is a component that can be created once and used multiple times across different parts of an application with different data using props. This reduces duplicate code and improves maintainability.

Code:

// Button.jsx
function Button({ label }) {
  return <button>{label}</button>;
}

export default Button;

Explanation

Reusable components accept props so they can display different content while using the same structure and logic. This makes them flexible and scalable for large applications.

Code:

// Using Button component multiple times
import Button from './Button';

function App() {
  return (
    <div>
      <Button label="Login" />
      <Button label="Register" />
    </div>
  );
}

Explanation

Common reusable components include UI elements like Button, Input, Card, Modal, Navbar, and Table because they appear frequently across multiple pages in an application.

Code:

src/
 ├── components/
 │    ├── Button.jsx
 │    ├── Input.jsx
 │    ├── Card.jsx
 │    └── Navbar.jsx

🚀 Learn Spring Boot with real-world projects

💡 Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
⚛️

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community