Components in Components
We can call components inside another component
Example:
// Filename - src/index.js:
import React from "react";
import ReactDOM from "react-dom";
const Greet = () => {
return <h1>Hello Geek</h1>
}
// This is a functional component
const Welcome = () => {
return <Greet />;
};
ReactDOM.render(
<Welcome />,
document.getElementById("root")
);
The above code will give the same output as other examples but here we have called the Greet component inside the Welcome Component.
For more information on components open Component Set 2
React Components
Components in React serve as independent and reusable code blocks for UI elements. They represent different parts of a web page and contain both structure and behavior. They are similar to JavaScript functions and make creating and managing complex user interfaces easier by breaking them down into smaller, reusable pieces.