Skip to content

Instantly share code, notes, and snippets.

@gilbox
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save gilbox/f398e8b01c2e2ab6e3ef to your computer and use it in GitHub Desktop.

Select an option

Save gilbox/f398e8b01c2e2ab6e3ef to your computer and use it in GitHub Desktop.
Functional React: The Renderer Component
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