Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active December 28, 2018 11:42
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dabit3/3d0d47c4a8bfccadfd5d15c58cfb1424 to your computer and use it in GitHub Desktop.
Save dabit3/3d0d47c4a8bfccadfd5d15c58cfb1424 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute } from 'react-router'
class App extends Component {
render () {
return (
<Router history={hashHistory}>
<Route path='/' component={Container}>
<IndexRoute component={Home} />
<Route path='address' component={Address} />
<Route path='*' component={NotFound} />
</Route>
</Router>
)
}
}
const Nav = () => (
<div>
<Link to='/'>Home</Link>&nbsp;
<Link to='/address'>Address</Link>
</div>
)
const Container = (props) => <div>
<Nav />
{props.children}
</div>
const Home = () => <h1>Hello from Home!</h1>
const Address = () => <h1>We are located at 555 Jackson St.</h1>
const NotFound = () => <h1>404.. This page is not found!</h1>
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment