Skip to content

Instantly share code, notes, and snippets.

@drenther drenther/App.js
Created Jun 17, 2018

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