Kris Yotamrevised entire site1a92d151 year agoHistory
38 lines · 764 B · TypeScript
RawDownload
"use client" import React, { type ErrorInfo } from "react" interface ErrorBoundaryProps {  children: React.ReactNode  fallback: React.ReactNode} interface ErrorBoundaryState {  hasError: boolean} class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {  constructor(props: ErrorBoundaryProps) {    super(props)    this.state = { hasError: false }  }   static getDerivedStateFromError(_: Error): ErrorBoundaryState {    return { hasError: true }  }   componentDidCatch(error: Error, errorInfo: ErrorInfo) {    console.error("Uncaught error:", error, errorInfo)  }   render() {    if (this.state.hasError) {      return this.props.fallback    }     return this.props.children  }} export default ErrorBoundary 

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t