From 57dc5a14818a98f7afedcd43b47a5a6abaeffbd6 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 4 Oct 2024 14:52:47 +0200 Subject: [PATCH] reset error so when doing a new request, error could be gone (#32974) fixes: #32847 Signed-off-by: Erik Jan de Wit --- js/libs/ui-shared/src/utils/ErrorBoundary.tsx | 4 ++-- js/libs/ui-shared/src/utils/useFetch.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/js/libs/ui-shared/src/utils/ErrorBoundary.tsx b/js/libs/ui-shared/src/utils/ErrorBoundary.tsx index 3d771cb9a7..adb8fd9064 100644 --- a/js/libs/ui-shared/src/utils/ErrorBoundary.tsx +++ b/js/libs/ui-shared/src/utils/ErrorBoundary.tsx @@ -10,7 +10,7 @@ import { useRequiredContext } from "./useRequiredContext"; export interface ErrorBoundaryContextValue { error?: Error; - showBoundary: (error: Error) => void; + showBoundary: (error?: Error) => void; } const ErrorBoundaryContext = createNamedContext< @@ -40,7 +40,7 @@ export class ErrorBoundaryProvider extends Component< return { error }; }; - showBoundary = (error: Error) => { + showBoundary = (error?: Error) => { this.setState({ error }); }; diff --git a/js/libs/ui-shared/src/utils/useFetch.ts b/js/libs/ui-shared/src/utils/useFetch.ts index 89f4eaecf0..09419d44f1 100644 --- a/js/libs/ui-shared/src/utils/useFetch.ts +++ b/js/libs/ui-shared/src/utils/useFetch.ts @@ -26,6 +26,7 @@ export function useFetch( useEffect(() => { const controller = new AbortController(); const { signal } = controller; + showBoundary(); adminClientCall() .then((result) => { if (!signal.aborted) {