Last active
July 6, 2017 19:28
-
-
Save glortho/1c1f2c0cd667287fa59d99bb44039080 to your computer and use it in GitHub Desktop.
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
import { localState } from 'jetset'; | |
@localState({ example: 'foo', example2: 'bar' }) | |
class LocalStateExample extends React.Component { | |
render() { | |
return ( | |
<div> | |
<div> | |
<span>example state: { this.props.example.get() }</span> | |
<button onClick={() => this.props.example.set( 'foo' )}>Set to foo</button> | |
<button onClick={() => this.props.localState.set({ example: 'bar' })}>Set to bar</button> | |
</div> | |
<div> | |
<span>example2 state: { this.props.example2.get() }</span> | |
<button onClick={() => this.props.example2.set( 'foo' )}>Set to foo</button> | |
<button onClick={() => this.props.localState.set({ example2: 'bar' })}>Set to bar</button> | |
</div> | |
</div> | |
); | |
} | |
} | |
export default LocalStateExample; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment