Reactjs 如何在react中观察渲染函数之外的mobx观察值?

Reactjs 如何在react中观察渲染函数之外的mobx观察值?,reactjs,mobx-react,Reactjs,Mobx React,我有一家mobx商店 class MyStore { @observable public myvariable = "" 以及当myvariable值更改时应更新其数据的视图 @inject("myStore") @observer class MyView extends React.Component<any, any> { @observable public mydata; // inside this class I have

我有一家mobx商店

class MyStore {
    @observable
    public myvariable = ""
以及当
myvariable
值更改时应更新其数据的视图

@inject("myStore")
@observer
class MyView extends React.Component<any, any> {
    @observable
    public mydata;

    // inside this class I have to know if `myvariable` value changed
    // if it does, I have to fetch some data to assign to `mydata` so
    // that I can render that new data
@inject(“myStore”)
@观察者
类MyView扩展了React.Component{
@可观察
公共数据;
//在这个类中,我必须知道'myvariable'值是否发生了变化
//如果有,我必须获取一些数据来分配给'mydata',所以
//我可以呈现这些新数据
我不想将
mydata
放在存储中,因为我有很多视图,每个视图都有不同类型的数据,如果
myvariable
值更改,可以更新这些数据。我只想更新当前显示的视图的
mydata

componentDidUpdate(prevProps){
    if(prevProps.myStore.myvariable !== this.props.myStore.myvariable){
        // update mydata
    }
}

太简单了。我错过了组件更新。谢谢