33 lines
899 B
TypeScript
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>
|
|
);
|
|
}
|