Created
June 7, 2014 23:47
-
-
Save mattatcha/e5032cf64e1a7840108e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var App = React.createClass({ | |
mixins: [FluxMixin, StoreWatchMixin("AuthStore"), RoutingContextMixin], | |
getStateFromFlux: function() { | |
var flux = this.getFlux(); | |
return { | |
Auth: flux.store("AuthStore").getState() | |
}; | |
}, | |
render: function() { | |
var path = this.getRouting().path; | |
// Handle login/logged out cases. | |
if (!this.state.Auth.isLoggedIn) { | |
this.navigate('/login'); | |
} else if(path === '/login') { | |
this.navigate('/dashboard'); | |
} else if (path === "/") { | |
this.navigate('/dashboard'); | |
} | |
// This is needed to pass the current context to the View. | |
var View = cloneWithProps(this.props.view, {}); | |
return ( | |
<div> | |
<Header currentUser={this.state.Auth.currentUser} isLoggedIn={this.state.Auth.isLoggedIn}/> | |
<div className="container"> | |
{View} | |
</div> | |
</div> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment