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

16 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorBoundaryProvider = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const errorBoundaryPortal_1 = require("./components/errorBoundaryPortal/errorBoundaryPortal"); const errorBoundaryContext_1 = require("./errorBoundaryContext"); const ErrorBoundaryProvider = ({ children, showErrorMessage = true, idCreateModal, customFallback, }) => { const [errors, setErrors] = (0, react_1.useState)([]); const getErrors = (error) => { setErrors(prev => [...prev, error]); }; return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(errorBoundaryContext_1.ErrorBoundaryContext.Provider, { value: { errors, getErrors, customFallback }, children: [errors.length && showErrorMessage ? ((0, jsx_runtime_1.jsx)(errorBoundaryPortal_1.ErrorBoundaryPortal, { errors: errors, portalId: idCreateModal })) : null, children] }) })); }; exports.ErrorBoundaryProvider = ErrorBoundaryProvider; //# sourceMappingURL=errorBoundaryProvider.js.map