Skip to content

Instantly share code, notes, and snippets.

@jamsesso
Last active July 10, 2016 16:29
Show Gist options
  • Save jamsesso/4ea0c449d65939c03baffd60b5633753 to your computer and use it in GitHub Desktop.
Save jamsesso/4ea0c449d65939c03baffd60b5633753 to your computer and use it in GitHub Desktop.
import React, { Component, PropTypes } from 'react'
import { render } from 'react-dom'
import withContext from './with-context'
import thread from './thread'
class Parent extends Component {
static childContextTypes = {
someContext1: PropTypes.object,
someContext2: PropTypes.object
}
render() {
return (
<Stuff>
{this.props.children}
</Stuff>
)
}
}
class Child extends Component {
render() {
console.log('Context:', this.context)
// -> Object { }
console.log('Props:', this.props)
// -> Object { someContext1: {...}, someContext2: {...} }
}
}
const withSomeContext1 = withContext('someContext1', PropTypes.object)
const withSomeContext2 = withContext('someContext2', PropTypes.object)
const WrappedChild = thread(Child, withSomeContext1, withSomeContext2)
render(
<Parent>
<WrappedChild />
</Parent>,
document.getElementById('root')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment