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/9d0344a02f834f4ca81b to your computer and use it in GitHub Desktop.

Select an option

Save gilbox/9d0344a02f834f4ca81b to your computer and use it in GitHub Desktop.
Functional React: Rudimentary State Change
const {fromJS} = require('immutable');
const data = fromJS({ name: 'gilbox' });
const Hello = component(function Hello ({name}, {edit}) {
return <div>
Hello, {name}!
<button onClick={event => edit(data => data.updateIn(['name'], 'Maude Lebowski') }>
Change My Name
</button>
</div>
});
const App = component(function App ({data}, {edit}) {
return <Hello name={data.get('name')} statics={{edit}} />
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment