here's my code:
export default class ViewStore {
templateName = '';
static views = [];
constructor(mainStore: MainStore) {
makeObservable(this, {
templateName: observable,
ViewStore.views: observable,
});
}
}
I want to define views as observable. I've tried referring to it by this. views and views but none of them worked either.
in mobX5 it was possible by defining @observable before views when defining it like this:
@observable static views = [];
but I don't know how to achieve this in mobX 6
Basically the same way as you did with MobX@5, but without decorator api:
import { observable } from "mobx";
export default class ViewStore {
templateName = '';
// Call observable as a function
static views = observable([]);
constructor(mainStore: MainStore) {
makeObservable(this, {
templateName: observable,
// No need this line
// ViewStore.views: observable,
});
}
}