mirror of
https://github.com/graphql-hive/console
synced 2026-05-24 09:38:26 +00:00
27 lines
535 B
TypeScript
27 lines
535 B
TypeScript
'use client';
|
|
|
|
import { Component } from 'react';
|
|
|
|
export class ErrorBoundary extends Component<{
|
|
fallback: React.ReactNode;
|
|
children: React.ReactNode;
|
|
}> {
|
|
state = { hasError: false };
|
|
|
|
static getDerivedStateFromError(error: Error) {
|
|
console.error(error);
|
|
return { hasError: true };
|
|
}
|
|
|
|
componentDidCatch(error: Error, info: { componentStack: string }) {
|
|
console.error(error, info);
|
|
}
|
|
|
|
render() {
|
|
if (this.state.hasError) {
|
|
return this.props.fallback;
|
|
}
|
|
|
|
return this.props.children;
|
|
}
|
|
}
|