diff --git a/src/components/TerminalErrorPage.tsx b/src/components/TerminalErrorPage.tsx index ee7541b..23056cb 100644 --- a/src/components/TerminalErrorPage.tsx +++ b/src/components/TerminalErrorPage.tsx @@ -17,6 +17,23 @@ interface TerminalErrorPageProps { disableTerminal?: boolean; } +// Safe router hook wrappers that return undefined if outside Route context +function useSafeNavigate() { + try { + return useNavigate(); + } catch { + return undefined; + } +} + +function useSafeLocation() { + try { + return useLocation(); + } catch { + return undefined; + } +} + export function TerminalErrorPage(props: TerminalErrorPageProps) { const [command, setCommand] = createSignal(""); const [history, setHistory] = createSignal([]); @@ -24,8 +41,8 @@ export function TerminalErrorPage(props: TerminalErrorPageProps) { const [btopOpen, setBtopOpen] = createSignal(false); let inputRef: HTMLInputElement | undefined; let footerRef: HTMLDivElement | undefined; - const navigate = useNavigate(); - const location = useLocation(); + const navigate = useSafeNavigate(); + const location = useSafeLocation(); const { isDark } = useDarkMode(); createEffect(() => { @@ -107,17 +124,19 @@ export function TerminalErrorPage(props: TerminalErrorPageProps) {
Quick actions:
{props.quickActions} - + + +