Created
August 8, 2021 21:01
-
-
Save stivncastillo/78d81f6742a176dc35a4f7388c1dd782 to your computer and use it in GitHub Desktop.
ROutes
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
import React from 'react' | |
import { | |
BrowserRouter as Router, | |
Switch, | |
Route, | |
Link, | |
} from "react-router-dom"; | |
import routes from './routes'; | |
import { PrivateRoute } from "./types.js"; | |
const Routes = () => { | |
return ( | |
<Router> | |
<div> | |
<nav> | |
<ul> | |
<li> | |
<Link to="/">Dashboard</Link> | |
</li> | |
<li> | |
<Link to="/login">Login</Link> | |
</li> | |
<li> | |
<Link to="/profile">Profile</Link> | |
</li> | |
</ul> | |
</nav> | |
<Switch> | |
{routes.private.map(({ path, component, name }) => ( | |
<PrivateRoute exact key={name} path={path} component={component} /> | |
))} | |
{routes.public.map(({path, component, name}) => ( | |
<Route exact path={path} component={component} key={name} /> | |
))} | |
</Switch> | |
</div> | |
</Router> | |
) | |
} | |
export default Routes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment