mobx-view-model
Version:
MobX ViewModel power for ReactJS
14 lines (13 loc) • 500 B
JavaScript
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 });
});