Last active
July 10, 2016 16:42
-
-
Save jamsesso/a3a27fd6250c7c739fc1b1ec291c3c1a 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' | |
class Parent extends Component { | |
static childContextTypes = { | |
someContext1: PropTypes.object, | |
someContext2: PropTypes.object | |
} | |
render() { | |
return ( | |
<Stuff> | |
{this.props.children} | |
</Stuff> | |
) | |
} | |
} | |
class Child extends Component { | |
static contextTypes = { | |
someContext1: PropTypes.object.isRequired, | |
someContext2: PropTypes.object.isRequired | |
} | |
render() { | |
console.log('Context:', this.context) | |
// -> Object { someContext1: {...}, someContext2: {...} } | |
console.log('Props:', this.props) | |
// -> Object { } (usually some stuff, but we don't care right now) | |
} | |
} | |
render( | |
<Parent> | |
<Child /> | |
</Parent>, | |
document.getElementById('root') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment