Last active
February 20, 2017 15:24
-
-
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.
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
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