Skip to content

<OnlyViewModel /> 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.

Component that creates an instance of a passed ViewModel class and renders nothing or the provided children.
If children is a function, it receives the created model.
ViewModelSimple is not supported here.

Example

tsx
import { ViewModelBase } from "mobx-view-model";
import { OnlyViewModel } from "mobx-view-model-react";

class TestVM extends ViewModelBase {
  foo = 100;
}

<OnlyViewModel model={TestVM} />

Released under the MIT License.