Skip to content

Instantly share code, notes, and snippets.

@stivncastillo
Created August 8, 2021 21:01
Show Gist options
  • Save stivncastillo/78d81f6742a176dc35a4f7388c1dd782 to your computer and use it in GitHub Desktop.
Save stivncastillo/78d81f6742a176dc35a4f7388c1dd782 to your computer and use it in GitHub Desktop.
ROutes
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