Last active
March 25, 2017 22:30
-
-
Save timwis/20443af54f047221465d0e6f2d1c13ef to your computer and use it in GitHub Desktop.
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 'foundation-sites/dist/css/foundation.css' | |
import TopBar from './TopBar' | |
class Layout extends React.Component { | |
render () { | |
<div className='container'> | |
<TopBar /> | |
{this.props.children} | |
</div> | |
} | |
} | |
export default Layout |
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 ReactDOM from 'react-dom' | |
import Layout from './Layout' | |
import Home from './Home' | |
import Submit from './Submit' | |
import './index.css' | |
const router = { | |
'': <Home />, | |
'submit': <Submit /> | |
} | |
window.onhashchange = renderCurrentRoute | |
renderCurrentRoute() | |
function renderCurrentRoute () { | |
const hash = window.location.hash.substr(1) | |
const component = router[hash] || router[''] | |
ReactDOM.render( | |
<Layout>{component}</Layout>, | |
document.getElementById('root') | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment