Skip to content

Instantly share code, notes, and snippets.

@jpgorman
Created April 19, 2018 10:15
Show Gist options
  • Save jpgorman/2ff3312ee04c69cc7cb01fb7c71ff4f5 to your computer and use it in GitHub Desktop.
Save jpgorman/2ff3312ee04c69cc7cb01fb7c71ff4f5 to your computer and use it in GitHub Desktop.
Use the DataProvider
class AsyncComponent extends React.Component {
componentDidMount() {
// use the context
if(!this.context.state.foo)
dataFetcher();
}
...
}
AsyncComponent.contextTypes = {
state: PropTypes.any,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment