Computed properties without @computed
import React from 'react';
import { observable, computed } from 'mobx';
import { observer } from 'mobx-react';
@observer class ParentComponent extends React.Component {
@observable isLoading = false;
@observable isSaving = false;
@computed get active() { return this.isLoading || this.isSaving; }
render() {
return (
<div>
<Spinner active={this.active}>
</div>
);
}
}PreviousUse observables instead of state in React componentsNextUse computed.struct for computed objects
Last updated