mobxjs / mobx-vue

🐉 Vue bindings for MobX
MIT License
475 stars 22 forks source link

Mobx 6 got `Exception: TypeError: Cannot read properties of undefined` on COLLECTION #83

Closed huybuidac closed 2 years ago

huybuidac commented 2 years ago

If using observable for COLLECTION, we got error while access any property of object.

export class VM {
  @observable histories: any[] = []

  constructor() {
    makeObservable(this)
    this.loadData()
  }

  @action.bound loadData() {
    this.histories = [
      { id: 1, name: 'test1' },
      { id: 2, name: 'test2' },
    ]
    console.log(this.histories)
  }
}

image

iChenLei commented 2 years ago

Maybe you should report this issue to mobxjs/mobx repository? @huybuidac

huybuidac commented 2 years ago

@iChenLei I don't see any unit test for collection on mobx-vue 2.1.0, you can make a simple unittest for it :(

I'm using with vuetify v-data-table, and got this error.

iChenLei commented 2 years ago

please provide minimal reprodcue code repo(codesandbox or stackblitz) or snippet, thanks.