kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 54 lines 1.3 kB view raw
1import React from "react"; 2import { ErrorDisplay } from "./error-display"; 3 4type ErrorBoundaryState = { 5 hasError: boolean; 6 error?: Error; 7}; 8 9type ErrorBoundaryProps = { 10 children: React.ReactNode; 11 fallback?: React.ComponentType<{ error: Error; resetError: () => void }>; 12}; 13 14export class ErrorBoundary extends React.Component< 15 ErrorBoundaryProps, 16 ErrorBoundaryState 17> { 18 constructor(props: ErrorBoundaryProps) { 19 super(props); 20 this.state = { hasError: false }; 21 } 22 23 static getDerivedStateFromError(error: Error): ErrorBoundaryState { 24 return { hasError: true, error }; 25 } 26 27 componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { 28 console.error("Error caught by boundary:", error, errorInfo); 29 } 30 31 resetError = () => { 32 this.setState({ hasError: false, error: undefined }); 33 }; 34 35 render() { 36 if (this.state.hasError) { 37 if (this.props.fallback && this.state.error) { 38 const FallbackComponent = this.props.fallback; 39 return ( 40 <FallbackComponent 41 error={this.state.error} 42 resetError={this.resetError} 43 /> 44 ); 45 } 46 47 return ( 48 <ErrorDisplay error={this.state.error} onRetry={this.resetError} /> 49 ); 50 } 51 52 return this.props.children; 53 } 54}