Skip to content

Instantly share code, notes, and snippets.

@hamatoyogi
Last active December 31, 2018 00:08
Show Gist options
  • Save hamatoyogi/a6ecceba67a44000a45e0d590f587db8 to your computer and use it in GitHub Desktop.
Save hamatoyogi/a6ecceba67a44000a45e0d590f587db8 to your computer and use it in GitHub Desktop.
@observer
export default class extends React.Component {
constructor() { ... } // for brevity
// define the data we want to "watch"
@observable chosenPhrase = this.randomPhrases[0];
@observable counter = 0;
// define an "action" -> we are saying what that we want to change a peice of "watched" data
@action
changeState() { ... } // for brevity
render() {
return (
<React.Fragment>
<Header className={this.props.className}>
Lean MobX React bullshit generator
</Header>
<MyButton className={this.props.className} onClick={this.changeState}>
Generate Some BS
</MyButton>
<h2>Go Tweet this:</h2>
<div>{this.chosenPhrase}</div>
<h3>Demonstration of Some Mobx state shit</h3>
<div> {`Button Clicked ${this.counter} Times`}</div>
</React.Fragment>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment