Files
clean-architecture-frontend…/src/platform/errors/feature-error-boundary.tsx
T

33 lines
899 B
TypeScript

import type { ReactNode } from "react";
import {
ScopedErrorBoundary,
type ScopedErrorBoundaryProps,
} from "./scoped-error-boundary.tsx";
/**
* Spec §30. Contains a feature-local render failure inside the feature's own
* subtree. The enclosing context boundary is the next escalation.
*/
export function FeatureErrorBoundary(
props: Readonly<{
featureId: string;
children: ReactNode;
fallback?: ReactNode;
resetKey?: string;
onError?: ScopedErrorBoundaryProps["onError"];
}>,
) {
return (
<ScopedErrorBoundary
scope="feature"
ownerId={props.featureId}
{...(props.fallback === undefined ? {} : { fallback: props.fallback })}
{...(props.resetKey === undefined ? {} : { resetKey: props.resetKey })}
{...(props.onError === undefined ? {} : { onError: props.onError })}
>
{props.children}
</ScopedErrorBoundary>
);
}