Files
SnowLuma/.pnpm-store/v11/files/fd/19f3f1b5b53355d696f6fa6a16ad3cb741add75efdbf950192ffc7c2ba48b2197f2092c0bb6bd5d516a2088f397c773ba4fdb521191e0268dbbdcfd6477605
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

25 lines
725 B
Plaintext

import { DOM_ERROR_HANDLER } from "../constants.js";
import { Fragment } from "./jsx-dev-runtime.js";
import "./jsx-runtime.js";
//#region src/jsx/dom/components.ts
const ErrorBoundary = (({ children, fallback, fallbackRender, onError }) => {
const res = Fragment({ children });
res[DOM_ERROR_HANDLER] = (err) => {
if (err instanceof Promise) throw err;
onError?.(err);
return fallbackRender?.(err) || fallback;
};
return res;
});
const Suspense = (({ children, fallback }) => {
const res = Fragment({ children });
res[DOM_ERROR_HANDLER] = (err, retry) => {
if (!(err instanceof Promise)) throw err;
err.finally(retry);
return fallback;
};
return res;
});
//#endregion
export { ErrorBoundary, Suspense };