How to load site styles for the v2 ErrorBoundary in the root.tsx? #6356
Replies: 2 comments 6 replies
-
The ErrorBoundary of your root must render the basic HTML document including export default function Component() {
return (
<Document>
<Outlet />
</Document>
)
}
export function ErrorBoundary() {
let error = useRouteError()
if (isRouteErrorResponse(error)) {
return (
<Document title={error.statusText}>
<h1>{error.status}</h1>
</Document>
)
}
return (
<Document title="Unknown Error ">
<h1>Unknown Error</h1>
</Document>
)
}
function Document(props: { children: ReactNode; title: string }) {
return (
<html>
<head>
{props.title ? <title>{props.title}</title> : null}
<Meta />
<Links />
</head>
<body>
{props.children}
<Scripts />
</body>
</html>
)
} |
Beta Was this translation helpful? Give feedback.
-
In a multiple tenant applications where configurations are defined using a loader (styles, translations etc), how can we create a fallback 404 Page using V2 ErrorBoundary? I understand the direction that ErrorBoundary in root should be deterministic since the error can occur in the root itself, but without having the Root wrapper we loose the capability of having fallback pages for the rest of the app. (404 pages does not mean a errored Root) I'm missing something or is this a limitation of the V2? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm migrating my app to the new v2 features but I'm struggling with the new ErrorBoundary.
I can't get it to work as before, where I had a global boundary that was displaying the errors in the context of my app.
Currently, when the error is thrown in the
root.tsx
file, it's rendered on a clean HTML file, without any styles as if thelinks
function was not rendered at all.root.tsx:
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions