Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Last active March 5, 2016 13:21
Show Gist options
  • Save aaronmcadam/960d62e4c448a2a03bd0 to your computer and use it in GitHub Desktop.
Save aaronmcadam/960d62e4c448a2a03bd0 to your computer and use it in GitHub Desktop.
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
ReactDOM.render(
<Router history={browserHistory} routes={routes} />,
document.querySelector('.container')
);
import React, { Component, PropTypes } from 'react';
class PostsNew extends Component {
static contextTypes = {
router: PropTypes.object
}
/// ... template for a Post form
onSubmit(props) {
this.props.createPost(props)
.then(() => {
this.context.router.push('/');
});
}
}
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './components/app';
import PostsIndex from './components/posts_index';
import PostsNew from './components/posts_new';
import PostsShow from './components/posts_show';
export default (
<Route path='/' component={App}>
<IndexRoute component={PostsIndex} />
<Route path='posts/new' component={PostsNew} />
<Route path='posts/:id' component={PostsShow} />
</Route>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment