Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

RenderErrorBoundary.tsx

16 lines418 Bytes

1import { Component, type ReactNode } from "react";
2​
3export class RenderErrorBoundary extends Component<
4 { readonly children: ReactNode; readonly fallback: ReactNode },
5 { readonly failed: boolean }
6> {
7 override state = { failed: false };
8​
9 static getDerivedStateFromError() {
10 return { failed: true };
11 }
12​
13 override render() {
14 return this.state.failed ? this.props.fallback : this.props.children;
15 }