Created
December 8, 2016 15:38
-
-
Save kellyrmilligan/7e812909271f223f9ba7275dd58cb378 to your computer and use it in GitHub Desktop.
This file contains 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, { PropTypes, Component } from 'react' | |
class ContextExample extends Component { | |
static childContextTypes = { | |
config: PropTypes.object, | |
} | |
getChildContext() { | |
return { | |
config: this.props.config, | |
} | |
} | |
render() { | |
return <div>{this.props.children}</div> | |
} | |
} | |
class UseContext extends Component { | |
static contextTypes = { | |
config: PropTypes.object | |
} | |
render() { | |
return <div>{this.context.config.value}</div> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Finaly a simple, working example, thanks!