【发布时间】:2019-12-27 12:04:16
【问题描述】:
我有一个班级:
class Field{
constructor(name) {
this.name= name
this.otherAttr = null
}
changeName(newName) {
this.name = newName
}
}
const f = new Field("Charanjit")
f.setName("Singh") // It shoukd reflect in observer
f.name = "Rahul" // It should also reflect in observer
如何使f 对象可观察,以便f 属性的任何更改都会更新观察者组件。
目前,我收到错误:https://github.com/mobxjs/mobx/issues/1932 如果我使用:
@observable(f)
>>> It shows Error: https://github.com/mobxjs/mobx/issues/1932
【问题讨论】:
标签: reactjs mobx mobx-react mobx-state-tree