Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Last active September 4, 2019 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeGinnivan/81392472cf0d57bb30a5f24a70112f0f to your computer and use it in GitHub Desktop.
Save JakeGinnivan/81392472cf0d57bb30a5f24a70112f0f to your computer and use it in GitHub Desktop.
class SomethingComponent extends React.Component {
componentWillMount() {
// If we don't have an article, load it
if (!this.props.article) {
this.props.dispatch(loadArticle(this.props.id))
}
}
render() {
if (this.props.loading) {
return <div>Loading...</div>
}
return <Article article={this.props.article} />
}
}
// For this example, we only have a single state tree
// so no need to use mapStateToProps to narrow the data
// we are connecting to
export default connect(state => state)(SomethingComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment