Skip to content

Instantly share code, notes, and snippets.

@kellyrmilligan
Created December 8, 2016 15:38
Show Gist options
  • Save kellyrmilligan/7e812909271f223f9ba7275dd58cb378 to your computer and use it in GitHub Desktop.
Save kellyrmilligan/7e812909271f223f9ba7275dd58cb378 to your computer and use it in GitHub Desktop.
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>
}
}
@goodinmech
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment