vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
18 lines (17 loc) • 422 B
text/typescript
export function serializeErrorInfo(errorInfo: unknown): null | {
componentStack?: string | undefined;
digest?: string | undefined;
} {
if(errorInfo == null || typeof errorInfo !== "object") {
return null;
}
const { componentStack, digest, ...rest } = errorInfo as {
componentStack?: string;
digest?: string;
};
return {
componentStack: componentStack,
digest: digest,
...rest,
};
}