diff --git a/packages/components/src/components/Layout.tsx b/packages/components/src/components/Layout.tsx index 4c4dfc2..4925abe 100644 --- a/packages/components/src/components/Layout.tsx +++ b/packages/components/src/components/Layout.tsx @@ -21,42 +21,17 @@ interface LayoutProps { * @param props.title - page title */ export default function Layout({ children, className, progress, error, title }: LayoutProps) { - const [showError, setShowError] = useState(false) - const errorMessage = error?.toString() - if (error) console.error(error) - - // Reset error visibility when error prop changes - useEffect(() => { - if (error) { - setShowError(true) - console.error(error) - } else { - setShowError(false) - } - }, [error]) - // Update title useEffect(() => { document.title = title ? `${title} - hyperparam` : 'hyperparam' }, [title]) - return
{children}
-
-
- {errorMessage} - -
-
+
{progress !== undefined && progress < 1 &&
@@ -75,3 +50,27 @@ function Sidebar() { export function Spinner({ className }: { className: string }) { return
} + +function ErrorBar({ error }: { error?: Error }) { + const [showError, setShowError] = useState(error !== undefined) + const [prevError, setPrevError] = useState(error) + + if (error) console.error(error) + /// Reset error visibility when error prop changes + if (error !== prevError) { + setPrevError(error) + setShowError(error !== undefined) + } + + return
+
+ {error?.toString()} + +
+
+}