import { useEffect } from "react" import { useRouteError } from "react-router-dom" import Button from "../../fundamentals/button" import RefreshIcon from "../../fundamentals/icons/refresh-icon" import WarningCircleIcon from "../../fundamentals/icons/warning-circle" type PageErrorElementProps = { origin: string } const isProd = process.env.NODE_ENV === "production" const RouteErrorElement = ({ origin }: PageErrorElementProps) => { const error = useRouteError() useEffect(() => { if (!isProd && error) { console.group( `%cAn error occurred in a page from ${origin}:`, "color: red; font-weight: bold;" ) console.error(error) console.groupEnd() } }, [error, origin]) const reload = () => { window.location.reload() } return (
{isProd ? "An error unknown error occurred, and the page could not be loaded." : `A Page from ${origin} crashed. See the console for more info.`}
What should I do?
If you are the developer of this page, you should fix the error and
reload the page. If you are not the developer, you should contact
the maintainer and report the error.