Skip to content

Instantly share code, notes, and snippets.

@didierfranc
Last active June 22, 2017 18:50
Show Gist options
  • Save didierfranc/555717d13d1916fdb8dd70bbed8afa35 to your computer and use it in GitHub Desktop.
Save didierfranc/555717d13d1916fdb8dd70bbed8afa35 to your computer and use it in GitHub Desktop.
import Login from './Login'
import Signup from './Signup'
import Header from './Header'
class Home extends React.Component {
componentWillMount = () => {
import('./Home').then(Component => {
this.Component = Component
this.forceUpdate()
})
}
render = () => (
this.Component ? <this.Component.default /> : null
)
}
const App = ({ user }) => (
<Body>
<Header />
{user.loggedIn ? <Route path="/" component={Home} /> : <Redirect to="/login" />}
<Route path="/signup" component={Signup} />
<Route path="/login" component={Login} />
</Body>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment