This website collects cookies to deliver better user experience
How To Create A Layout Component: React
How To Create A Layout Component: React
When creating a react application/website, most of the pages would be sharing the same content all over, other than importing each component in every page to be rendered, it is much easier and faster to just create a layout component.
Here is how to do it:
1. Create a new file called Layout.js (could be any name of choice)
2. Create a function component
You can choose either class component or function component that works best for you 😄
const Layout = () => {
return (
<div></div>
)
}
3. Add a prop called children to allow the components to be used as an HTML tag with both opening and closing tags i.e