Last active
August 29, 2015 14:23
-
-
Save gilbox/f398e8b01c2e2ab6e3ef to your computer and use it in GitHub Desktop.
Functional React: The Renderer Component
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
| const {fromJS} = require('immutable'); | |
| const data = fromJS({ name: 'gilbox' }); | |
| const rendererMixin = { | |
| getInitialState() { | |
| return {data:this.props.data} | |
| }, | |
| edit (transform) { | |
| this.setState({data: transform(this.state.data)}) | |
| } | |
| }; | |
| const Renderer = component(rendererMixin, function Renderer() { | |
| return <App | |
| data={this.state.data} | |
| statics={{ edit:this.edit }} /> | |
| }); | |
| const el = document.getElementById('app'); | |
| React.render(<Renderer data={data} />, el); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment