Skip to content

Instantly share code, notes, and snippets.

@glortho
Last active July 6, 2017 19:28
Show Gist options
  • Save glortho/1c1f2c0cd667287fa59d99bb44039080 to your computer and use it in GitHub Desktop.
Save glortho/1c1f2c0cd667287fa59d99bb44039080 to your computer and use it in GitHub Desktop.
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