Skip to content

Instantly share code, notes, and snippets.

@diegocasmo
Last active February 20, 2017 15:24
Show Gist options
  • Save diegocasmo/370263a0a59f4e6ecd3634768b95df1d to your computer and use it in GitHub Desktop.
Save diegocasmo/370263a0a59f4e6ecd3634768b95df1d to your computer and use it in GitHub Desktop.
This component implements the context feature, and exposes the prop called appData to other components. The whole application is going to be wrapped by it.
class Provider extends React.Component {
getChildContext() {
return {appData: this.props.appData};
}
render() {
return(
<div>
{this.props.children}
</div>
);
}
}
Provider.childContextTypes = {
appData: React.PropTypes.object.isRequired
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment