Minified error #2
: ViewModel
not found
This happened because your vmLookup
provided for hook useViewModel
is not found in ViewModelStore
.
Explanation:
Hook
tsx
const model = useViewModel(YourVM);
Will use ViewModelStore
to find your instance of provided YourVM
ViewModel
.
It means that your ViewModel
is not created yet and not registered in ViewModelStore
or you have not declared the creation of this ViewModel
anywhere.
Potential solution
Create and register your ViewModel
using useCreateViewModel
hook or withViewModel
HOC.
tsx
const model = useCreateViewModel(YourVM);
Also you can create and register your ViewModel
using ViewModelStore.attach() method, but then you will need to completely reproduce the cycle of creating and destroying the ViewModel
, which is described in the original code of the hook.