UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

12 lines 846 B
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { useState } from 'react'; import { ErrorBoundaryPortal } from './components/errorBoundaryPortal/errorBoundaryPortal'; import { ErrorBoundaryContext } from './errorBoundaryContext'; export const ErrorBoundaryProvider = ({ children, showErrorMessage = true, idCreateModal, customFallback, }) => { const [errors, setErrors] = useState([]); const getErrors = (error) => { setErrors(prev => [...prev, error]); }; return (_jsx(_Fragment, { children: _jsxs(ErrorBoundaryContext.Provider, { value: { errors, getErrors, customFallback }, children: [errors.length && showErrorMessage ? (_jsx(ErrorBoundaryPortal, { errors: errors, portalId: idCreateModal })) : null, children] }) })); }; //# sourceMappingURL=errorBoundaryProvider.js.map