0

I am trying to use the createViewModel from mobx-utils in a Mobx/React app.

My Store is:

export class CompanyStore extends StoreExt {   
   @observable
   companyDetails: ICompanyDetails = {}
}

And when i use the 'createViewModel' function, in the component like so:

function CompanyDetails() {
   const { companyStore } = useRootStore()
   const test = createViewModel(companyStore.companyDetails);
}

I getting this error:

Uncaught TypeError: Object(...) is not a function
at new ViewModel (mobx-utils.module.js?1a9d:629)
at createViewModel (mobx-utils.module.js?1a9d:775)
at CompanyDetails (index.tsx?dbb5:21)
at eval (observer.js?796d:24)
at eval (useObserver.js?338c:91)
at trackDerivedFunction (mobx.es6.js?cacc:668)
at Reaction.track (mobx.es6.js?cacc:1705)
at eval (useObserver.js?338c:89)
at useQueuedForceUpdateBlock (useQueuedForceUpdate.js?20c5:19)
at useObserver (useObserver.js?338c:83)

What could the cause be?

Diego
  • 594
  • 2
  • 10
  • 29
levi
  • 1,077
  • 2
  • 11
  • 24

1 Answers1

0

Well, The issue was an incompatibility between Mobx and mobx-utils packages. By matching them to the same version, the issue was solved.

Diego
  • 594
  • 2
  • 10
  • 29
levi
  • 1,077
  • 2
  • 11
  • 24