Created
August 28, 2018 07:18
-
-
Save r17x/4dc10f323592b63d0897c138c856e01e to your computer and use it in GitHub Desktop.
Article:react-roles
This file contains hidden or 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, {Fragment} from 'react'; | |
| import { | |
| BrowserRouter as Router, | |
| Route, | |
| Link | |
| } from "react-router-dom"; | |
| import {Admin, User} from './Auth'; // Add this line | |
| const Navigation = () => ( | |
| <ul style={{display: "flex", justifyContent: "space-around" }}> | |
| <li><Link to="/"> Home </Link></li> | |
| <li><Link to="/admin"> Admin Page </Link></li> | |
| <li><Link to="/user"> User Page </Link></li> | |
| </ul> | |
| ); | |
| const HomeComponent = () => ( | |
| <h1>Selamat datang</h1> | |
| ); | |
| const AdminComponent = () => ( | |
| <h1>Hai Admin, Kamu cantik deh!</h1> | |
| ); | |
| const UserComponent = () => ( | |
| <h1>Hai user, Jomblo kan!</h1> | |
| ); | |
| /** | |
| * Implement | |
| * - Admin(AdminComponent) | |
| * - User(UserComponent) | |
| * Line 41 & 42 | |
| */ | |
| const MainRouter = () => ( | |
| <Router> | |
| <Fragment> | |
| <Navigation/> | |
| <Route path="/" component={HomeComponent} exact={true} /> | |
| <Route path="/admin" component={Admin(AdminComponent)} /> | |
| <Route path="/user" component={User(UserComponent)} /> | |
| </Fragment> | |
| </Router> | |
| ); | |
| export default MainRouter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment