Skip to content

Instantly share code, notes, and snippets.

@nummi
Last active August 25, 2017 21:40
Show Gist options
  • Save nummi/7e927bfcf6a8cfe834d0c6f033e82124 to your computer and use it in GitHub Desktop.
Save nummi/7e927bfcf6a8cfe834d0c6f033e82124 to your computer and use it in GitHub Desktop.
React Contextual Component
// 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