Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = function(){
- return {
- getInitialState: function () {
- return {
- routeComponent: null
- };
- },
- runRoute: function(component){
- this.setState({routeComponent: component});
- this.forceUpdate();
- },
- componentWillMount: function() {
- var self = this;
- self.router = Router(self.routes).configure({
- resource: self,
- notFound: self.notFound
- });
- self.router.init();
- }
- };
- }
- module.exports = function(React, Router, NotFound, Profile, Board) {
- return React.createClass({
- mixins: [Router],
- routes: {
- '/board': 'trending',
- '/board/mostloved': 'mostLoved',
- '/profile': 'profile'
- },
- trending: function() {
- this.runRoute(
- <Board title="Trending Boards" setTitle={this.props.setTitle} />
- );
- },
- mostLoved: function() {
- this.runRoute(
- <Board title="Loved Boards" setTitle={this.props.setTitle} />
- );
- },
- profile: function() {
- this.runRoute(
- <Profile setTitle={this.props.setTitle} />
- );
- },
- notFound: function () {
- this.runRoute(
- <NotFound setTitle={this.props.setTitle} />
- );
- },
- render: function() {
- return this.state.routeComponent;
- }
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement