From 1225d8b546c1e5093047d8e6e8a46d053f051d97 Mon Sep 17 00:00:00 2001 From: Mayursinh Sarvaiya Date: Tue, 29 Nov 2022 21:35:45 +0530 Subject: [PATCH] fix: error component showing inaccurate errors. Fixes #9274 (#10128) Signed-off-by: Mayursinh Sarvaiya --- ui/src/app/shared/components/error-notice.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/src/app/shared/components/error-notice.tsx b/ui/src/app/shared/components/error-notice.tsx index 4570565153a2..7efc17b0f0de 100644 --- a/ui/src/app/shared/components/error-notice.tsx +++ b/ui/src/app/shared/components/error-notice.tsx @@ -10,7 +10,12 @@ export const ErrorNotice = (props: {style?: CSSProperties; error: Error & {respo if (!props.error) { return null; } - const [error, setError] = useState(props.error); // allow us to close the error panel - in case it does not get automatically closed + const [error, setError] = useState(() => props.error); // allow us to close the error panel - in case it does not get automatically closed + + useEffect(() => { + setError(props.error); + }, [props.error]); + // This timer code is based on https://stackoverflow.com/questions/57137094/implementing-a-countdown-timer-in-react-with-hooks const reloadAfterSeconds = props.reloadAfterSeconds || 120; const reload = props.onReload;