Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML.
components come in two types, Class components and Function components
If it react component can start captial Letter, all react component "JavaScript functions" but JavaScript functions not a react components.
An react component to return HTML tags
TYPES OF COMPONENTS
1.Functional Components
Simple JavaScript functions that return JSX.
Use React Hooks (useState, useEffect, etc.).
Example:
function Hello(){
return (
<h1>React Components</h1>
);
}
export default Hello;
- Class components
Use ES6 classes and render() method.
Support lifecycle methods.
Top comments (0)