UNPKG

@mic-rexjs/usecases-react

Version:

React-based solution for use usecases of Clean Architecture

21 lines 866 B
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; const _excluded = ["usecase"]; import { jsx as _jsx } from "react/jsx-runtime"; import { useUseCase } from '../../hooks/useUseCase'; import { SafeUseCaseFragment } from '../SafeUseCaseFragment'; import { Fragment, useContext } from 'react'; import { contextUseCase } from '../../usecases/contextUseCase'; export const UseCaseFragment = _ref => { let usecase = _ref.usecase, props = _objectWithoutProperties(_ref, _excluded); const _useUseCase = useUseCase(contextUseCase), getUseCaseContext = _useUseCase.getUseCaseContext; const context = getUseCaseContext(usecase); const contextValue = useContext(context); return _jsx(Fragment, { children: contextValue === null ? null : _jsx(SafeUseCaseFragment, { usecase: usecase, ...props }) }); };