Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/** @jsx React.DOM */
var React = require('./vendor/js/react');
var page = require('./vendor/js/page');
var jQuery = require('./vendor/js/jquery');
var Page1 = React.createClass({
render: <div>Hi!</div>
});
var Page2 = React.createClass({
render: function () {
return <div>what?</div>
}
});
var PageNotFound = React.createClass({
render: function() {
return <div>Page Not Found</div>
}
});
var Router = React.createClass({
render: function () {
return this.state.component;
},
getInitialState: function () {
return { component: <div /> };
},
componentDidMount: function () {
var self = this;
page('/', function (ctx) {
self.setState({ component: <Page1 /> });
});
page('/users/:id', function (ctx) {
self.setState({ component: <Page2 params={ctx.params} /> });
});
page('*', function (ctx) {
self.setState({ component: <PageNotFound /> });
});
page.start();
}
});
jQuery(document).ready(function(){
React.render(<Router />, document.getElementById('body'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.