Last active
July 10, 2016 16:29
-
-
Save jamsesso/4ea0c449d65939c03baffd60b5633753 to your computer and use it in GitHub Desktop.
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
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