phx-react
Version:
PHX REACT
25 lines • 1.13 kB
JavaScript
;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LexicalErrorBoundary = LexicalErrorBoundary;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_2 = require("react");
const react_error_boundary_1 = require("react-error-boundary");
function LexicalErrorBoundary({ children, onError }) {
const wrappedOnError = (0, react_2.useCallback)((err, info) => {
onError(err instanceof Error ? err : new Error(String(err), { cause: err }), info);
}, [onError]);
return (react_1.default.createElement(react_error_boundary_1.ErrorBoundary, { fallback: react_1.default.createElement("div", { style: {
border: '1px solid #f00',
color: '#f00',
padding: '8px',
} }, "An error was thrown."), onError: wrappedOnError }, children));
}
//# sourceMappingURL=LexicalErrorBoundary.js.map