Last active
March 5, 2016 13:21
-
-
Save aaronmcadam/960d62e4c448a2a03bd0 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
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') | |
); |
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
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('/'); | |
}); | |
} | |
} |
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
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