What Are React Components?
React components are the building blocks of any React application. They encapsulate the UI and behavior of an element and can be reused throughout the app.
Types of React Components
- Functional Components: Simple JavaScript functions that return JSX.
- Class Components: ES6 classes that extend
React.Componentand include arendermethod.
1 Functional Components
Functional components are the most common type of components in modern React applications. They are simple and allow the use of hooks.
App.js
</>
Copy
import React from 'react';
function App() {
return (
<h2>Hello World</h2>
);
}
export default App;
Output
