UNPKG

mobx-view-model

Version:
14 lines (13 loc) 500 B
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; import { observer } from 'mobx-react-lite'; import { useCreateViewModel, } from '../hooks/index.js'; export const OnlyViewModel = observer(({ model, config, payload, children, }) => { const vm = useCreateViewModel(model, payload, config); if (!vm.isMounted) { return null; } if (typeof children === 'function') { return children(vm); } return _jsx(_Fragment, { children: children }); });