Skip to content

Instantly share code, notes, and snippets.

@adeleke5140
Created May 8, 2022 16:32
Show Gist options
  • Save adeleke5140/9e9294554dad3ee355fea43965139216 to your computer and use it in GitHub Desktop.
Save adeleke5140/9e9294554dad3ee355fea43965139216 to your computer and use it in GitHub Desktop.
A Layout React Component using React Router
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