Skip to content

Instantly share code, notes, and snippets.

@kellyrmilligan
Created December 8, 2016 15:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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>
}
}
@SuperManEver
Copy link

thank you

@fampat
Copy link

fampat commented Apr 17, 2018

Finaly a simple, working example, thanks!

@goodinmech
Copy link

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