Skip to content

Instantly share code, notes, and snippets.

@timwis timwis/layout.js
Last active Mar 25, 2017

Embed
What would you like to do?
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
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
You can’t perform that action at this time.