Last active
December 31, 2018 00:08
-
-
Save hamatoyogi/a6ecceba67a44000a45e0d590f587db8 to your computer and use it in GitHub Desktop.
This file contains 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
@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