Last active
August 25, 2017 21:40
-
-
Save nummi/7e927bfcf6a8cfe834d0c6f033e82124 to your computer and use it in GitHub Desktop.
React Contextual Component
This file contains 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
// https://codesandbox.io/s/kxzwolv9k7 | |
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
class Ember extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { isCool: 'yasss' }; | |
} | |
render() { | |
const content = this.props.children({ | |
isCool: this.state.isCool | |
}); | |
return ( | |
<div>{content}</div> | |
); | |
} | |
} | |
const App = () => | |
<Ember> | |
{ | |
({ isCool }) => | |
<div> | |
Ember is cool? {isCool} | |
</div> | |
} | |
</Ember>; | |
render(<App />, document.getElementById('app')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment