Created
October 23, 2014 17:15
-
-
Save iammerrick/d34f06bec4f9928ebe38 to your computer and use it in GitHub Desktop.
Halp!
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
/** @jsx React.DOM **/ | |
var React = require('react'); | |
module.exports = React.createClass({ | |
propTypes: { | |
navigationStore: React.PropTypes.shape({ | |
fetch: React.PropTypes.func, | |
all: React.PropTypes.func | |
}) | |
}, | |
getInitialState() { | |
return { | |
pages: this.props.navigationStore.all() | |
}; | |
}, | |
componentWillMount() { | |
this.props.navigationStore.fetch(); | |
this.props.navigationStore.addChangeListener(this.handleNavigationStoreChange); | |
}, | |
componentWillUnmount() { | |
this.props.navigationStore.removeChangeListener(this.handleNavigationStoreChange); | |
}, | |
handleNavigationStoreChange() { | |
this.setState({ | |
pages: this.props.navigationStore.all() | |
}); | |
}, | |
render() { | |
var pages = this.state.pages.map((page) => { | |
return ( | |
<li key={page.id}>{page.title}</li> | |
); | |
}); | |
return ( | |
<div> | |
<h1>Hello World!</h1> | |
<ul> | |
{pages} | |
</ul> | |
{this.props.activeRouteHandler} | |
</div> | |
); | |
} | |
}); |
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
/** @jsx React.DOM **/ | |
var React = require('react'); | |
module.exports = React.createClass({ | |
render() { | |
return ( | |
<h1>Cards</h1> | |
); | |
} | |
}); |
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
/** @jsx React.DOM */ | |
var Router = require('react-router'); | |
var Routes = Router.Routes; | |
var Route = Router.Route; | |
var DefaultRoute = Router.DefaultRoute; | |
var NavigationStore = require('./AppHandler/stores/NavigationStore'); | |
var AppHandler = require('./AppHandler'); | |
var HomeHandler = require('./HomeHandler'); | |
module.exports = ( | |
<Routes location='history'> | |
<Route name='App' path='/' handler={AppHandler} navigationStore={new NavigationStore()}> | |
<DefaultRoute handler={HomeHandler} /> | |
</Route> | |
</Routes> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment