Skip to content
⚠️You are viewing an older version. Switch to the latest version (v11.x).View latest →

Warning #1: ViewModelStore not found ​

Full Text: ​

Unable to get access to view model by id or class name without using ViewModelStore
Last active view model will be returned.

Explanation: ​

This happened because the vmLookup passed as the first argument to the useViewModel hook does not work when ViewModelStore is not provided by <ViewModelsProvider>.

tsx
const model = useViewModel(YourVM);

// where YourVM - is vmLookup

This code tries to find YourVM in ViewModelStore, but ViewModelStore is not provided.

Potential solution ​

To fix this warning message, use <ViewModelsProvider> to provide ViewModelStore:

tsx
export const App = () => {
  return <ViewModelsProvider value={vmStore}>...</ViewModelsProvider>;
};