TanStackT
TanStack9mo ago
12 replies
military-pink

Unstyled flash after navigating away from errorComponent?

- Initially rendered errorComponent: Error which somehow ran fine.
- Shortly after implementing tsquery, my CSS stopped working in errorComponent.
- Saw that none of the head content was rendering in the error component anymore.
- Went through docs and realized I was apparently supposed to wrap a <RootDocument> around the errorComponent, so I put that up.

Though the styles are back while in errorComponent, now whenever I navigate out of it, like clicking a <Link to="/">, I get a flash of unstyled content on arrival. It's as if this <RootDocument> thing we're doing is unloading the <RootDocument> tied to errorComponent on exit, then loading the one around the regular Outlet shortly after loading the route we navigated to, which might be causing the flash? I noticed the entire <head> content shows rerender activity in devtools while this happens, which doesn't usually happen when going from one normal route to another.

- After this happens, if I backroute to the error component (browser back button) I get another flash of unstyled content.
- This whole thing also causes the favicon to switch to a favicon from some other app I was working on a few weeks ago, probably pulling from cache since it loses track of the current head data while this happens?
Was this page helpful?