Last active
June 22, 2017 18:50
-
-
Save didierfranc/555717d13d1916fdb8dd70bbed8afa35 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 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