Created
May 8, 2022 16:32
-
-
Save adeleke5140/9e9294554dad3ee355fea43965139216 to your computer and use it in GitHub Desktop.
A Layout React Component using React Router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Layout = ({ children }) => { | |
return( | |
<React.Fragment> | |
<Header/> | |
<div className ="wrapper"> | |
<Navigation /> | |
<main>{ children } </main> | |
</div> | |
</React.Fragment> | |
) | |
} | |
export default Layout; | |
//in the index.js file | |
import {BrowserRouter as Router, Route } from 'react-router-dom' | |
import Layout from '../components/Layout' | |
import Home from '../pages/Home' | |
const Pages = () => { | |
return( | |
<Router> | |
<Layout> | |
<Route path="/" component ={Home}/> | |
</Layout> | |
</Router> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment