Created
June 17, 2018 16:59
-
-
Save drenther/bef73cd084a8802d0d5eb19465ca784c to your computer and use it in GitHub Desktop.
App.js for react-ssr
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, { Component } from 'react'; | |
import { Switch, Navlink, Route } from 'react-router-dom'; | |
import Navbar from './components/Navbar'; | |
import NoMatch from './components/NoMatch'; | |
import UniversalDataloader from './components/UniversalDataloader'; | |
import routes from './routes'; | |
class App extends Component { | |
render() { | |
return ( | |
<div className="app"> | |
<Navbar /> | |
<main> | |
<Switch> | |
{routes.map(({ path, exact, C, ...rest }) => ( | |
<Route | |
key={path} | |
path={path} | |
exact={exact} | |
render={props => ( | |
<UniversalDataloader {...props} {...rest}> | |
{dataProps => <C {...dataProps} />} | |
</UniversalDataloader> | |
)} | |
/> | |
))} | |
<Route render={props => <NoMatch {...props} />} /> | |
</Switch> | |
</main> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment