An action transaction, , , , action. action, .
- (JS Bin)
@observer
class App extends Component {
@observable x = 'a';
@observable y = 'b';
@computed get z() {
console.log('computing z...');
return `${this.x} ${this.y}`;
}
onClick = action(() => {
this.x = 'c';
this.y = 'd';
});
render() {
return <div onClick={this.onClick}> {this.z} </div>;
}
}
- (JS Bin)
@observer
class App extends Component {
@observable x = 'a';
@observable y = 'b';
@computed get z() {
console.log('computing z...');
return `${this.x} ${this.y}`;
}
onClick = () => {
this.x = 'c';
this.y = 'd';
};
render() {
return <div onClick={this.onClick}> {this.z} </div>;
}
}