Created
April 23, 2018 20:49
-
-
Save kevinkassimo/8d3a4638661566a1e7923340d4474ebe to your computer and use it in GitHub Desktop.
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
const { provider, consumer } = createDecorator(); | |
@provider('red') | |
class App extends React.Component { | |
render() { | |
return <Button />; | |
} | |
} | |
@consumer('color') | |
class Button extends React.Component { | |
render() { | |
return ( | |
<button | |
style={{ color: this.props.color }} | |
onClick={() => this.props.setColor('green')}> | |
Click Me! | |
</button> | |
); | |
} | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment