Created
June 11, 2020 02:22
-
-
Save abelsan/87faa49344d426de68c244e59707709e to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='UTF-8'> | |
<script src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script src='https://unpkg.com/react-router@5/umd/react-router.min.js'></script> | |
<script src='https://unpkg.com/react-router-dom@5/umd/react-router-dom.min.js'></script> | |
<script src='https://unpkg.com/babel-standalone@6.26.0/babel.js'></script> | |
</head> | |
<body> | |
<div id='root'></div> | |
<script type='text/babel'> | |
const Link = ReactRouterDOM.Link, | |
Route = ReactRouterDOM.Route; | |
const App = props => ( | |
<ReactRouterDOM.HashRouter> | |
<ul> | |
<li><Link to="/">HOME</Link></li> | |
<li><Link to="/about">ABOUT</Link></li> | |
<li><Link to="/products">PRODUCTS</Link></li> | |
</ul> | |
<Route path="/" exact component={Home} /> | |
<Route path="/about" component={about} /> | |
<Route path="/products" component={products} /> | |
</ReactRouterDOM.HashRouter> | |
) | |
const Home = props => <h1>Home Page</h1> | |
const about = props => <h1>About the organization</h1> | |
const products = props => <h1>We make great products!</h1> | |
ReactDOM.render(<App />, document.querySelector('#root')); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment