Skip to content

ViewModelsProvider Component

Deprecated: React APIs from mobx-view-model

Everything related to the React integration must be imported from mobx-view-model-react. Re-exports on the root mobx-view-model entry are deprecated and may be removed in a future major version.

A context provider component that establishes a ViewModelStore instance for the React component tree, enabling centralized ViewModel management and cross-component access.

API Signature

tsx
function ViewModelsProvider(props: { children: ReactNode; value: ViewModelStore }): ReactNode;

Usage

tsx
import { ViewModelStoreBase } from "mobx-view-model";
import { ViewModelsProvider } from "mobx-view-model-react";

const vmStore = new ViewModelStoreBase();

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

Released under the MIT License.