Last active
July 10, 2016 16:42
-
-
Save jamsesso/d62b263c57a1c3de82929796a1557cfc 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' | |
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 = withSomeContext1(withSomeContext2(Child)) | |
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