[ES6 Class function] how do subclasses modify parent class attribute values?

related codes

class BaseStore {
    @observable statusTabActiveKey = 0
}

class ListStore extends BaseStore {
    @action.bound
    handleTabChange(index) {
        super.statusTabActiveKey = index
    }
}

const baseStore = new BaseStore()
const listStore = new ListStore()
export {
    baseStore,
    listStore,
}

what result do you expect? What is the error message actually seen?

I hope baseStore.statusTabActiveKey can modify

according to listStore.handleTabChange (2) method.
Jan.13,2022

is crooked, which is possible, because new BaseStore () and new BaseStore () are isolated. No matter how listStore calls handleTabChange , you cannot change the statusTabActiveKey in the instance baseStore . You can directly declare it as static , which is shared.

Menu