Last active
August 29, 2015 14:23
-
-
Save gilbox/9d0344a02f834f4ca81b to your computer and use it in GitHub Desktop.
Functional React: Rudimentary State Change
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 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