From c8ec32c55f2d8cf82c177ed6df0b45dcf6b3c4a7 Mon Sep 17 00:00:00 2001 From: flourishbar Date: Tue, 28 Jul 2026 07:27:52 +0100 Subject: [PATCH] fix(ErrorBoundary): preserve errorCount in custom fallback retry path (#223) --- components/ErrorBoundary.tsx | 4 +- components/Navbar.tsx | 4 +- components/__tests__/ErrorBoundary.test.tsx | 56 +++++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/components/ErrorBoundary.tsx b/components/ErrorBoundary.tsx index 7c6783f..3b9f491 100644 --- a/components/ErrorBoundary.tsx +++ b/components/ErrorBoundary.tsx @@ -4,7 +4,7 @@ import React, { Component, ErrorInfo, ReactNode } from 'react'; interface Props { children?: ReactNode; - fallback?: (error: Error, reset: () => void) => ReactNode; + fallback?: (error: Error, retry: () => void, reset: () => void) => ReactNode; onError?: (error: Error, errorInfo: ErrorInfo) => void; } @@ -108,7 +108,7 @@ export class ErrorBoundary extends Component { } if (this.props.fallback) { - return this.props.fallback(this.state.error!, this.reset); + return this.props.fallback(this.state.error!, this.retry, this.reset); } return React.createElement('div', { className: 'flex items-center justify-center min-h-[200px]' }, diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 430dbc7..2799fc1 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -67,10 +67,10 @@ export function Navbar() { undefined value in a widget's state hook) shouldn't blank the whole header, just fall back to a compact retry (fixes #191). */} ( + fallback={(_error, retry) => (