-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flash of Unstyled Content in V2 #7516
Comments
actually just reverted back to I feel like i'm just going to have to bundle ALL my CSS and not have any route-specific stuff |
The flash of unstyled content is not related to V2, I had the same issue with V1 and I resolved the issue by wrapping my routes with a loading component when the page isn't hydrated. import { type ReactNode } from "react";
import { useHydrated } from "remix-utils";
export function Loading({ children }: { children: ReactNode }) {
const isHydrated = useHydrated();
if (isHydrated) {
return (
<div className="animate-appear">{children}</div>
);
}
return (
<div>Loading...</div>
);
} |
Wrapping all pages in a loading spinner is inherently anti-remix and should not be used as the default - or the solution. To contrast where this is intended, take a look at the docs for streaming in remix. Are there any updates on this issue? |
Could you provide a reproduction repo for troubleshooting? |
FWIW, i switched from styled-components to vanilla CSS when i upgraded to V2 as well, so other users are right - it might totally be a v1 thing as well, that i just never noticed because i had an extra render happening to inject the styled-components stylesheet @brophdawg11 i can work on getting a repro case when i get some time away from work |
@brophdawg11 most minimal example of just some content |
This comment was marked as outdated.
This comment was marked as outdated.
@ngbrown yep totally understand this. but the issue is remix boasts about it's route-based styles, and if they provide an objectively worse experience, then it's not really a usable feature. FWIW, i did end up combining my stylesheets into one that gets loaded on first visit, and it solved the problem, but either remix needs to figure this issue out or stop recommending people use route-loaded styles. |
This same sort of issue exists for developers who want to split i18next strings into separate namespaces. You have to follow the same convention here of either combining all the assets/strings or preloading nearby assets in anticipation of navigation to another route. Ideally there would be a mechanism for routes to specify assets necessary for the first render (after the initial page load) like style sheets and translation strings. |
This is a bug in Remix. It got introduced when we switched the internals of Remix to use React Router's |
This is resolved by #7576 and will be included in the next release 👍 |
🤖 Hello there, We just published version Thanks! |
Hello 👋 We're experiencing a similar issue to OP on The screenshot is taken running in development. Here's a video that demonstrates the issue. |
@sourcec0de I don't think you're reporting the same issue. Your video shows a FOUC on initial page load. OP's issue was a FOUC on client-side navigations to lazily loaded routes with CSS with caching disabled. Can you open a new issue with a reproduction so we can look into your initial load FOUC? |
@sourcec0de i'm assuming this will go away if you revert back to but definitely worth a new remix issue either way |
🤖 Hello there, We just published version Thanks! |
I'm still experiencing the same as @sourcec0de on 2.1.0 |
@tb-b Could you open a new issue with a reproduction? |
This flash issue is still coming with remix 2.3.1 and react@18.2.0. So, I switched to It confirms that flash issue is related to React not with Remix. |
Thanks @AmreeshTyagi . I ended up deploying Do you know what else changed in React v18.3? Before: After: |
Upgrading to react 18.3.0-canary-338dddc08-20240307 resolved our issue |
I am also seeing a Flash for a millisecond without styles when I switched from plain Remix to Vite based setup. I didn't see it before Vite switch. Not using any canary versions. |
i am using remix cloudflare setup , noticed this issue on first visit when page is not cached . |
The issue is resoled , I found that FOUC was happening because of third-party extension (Grammarly) , removed it and now FOUC gone in initial load , export function ErrorBoundary() {
const error = useRouteError();
console.error(error);
return (
<html>
<head>
<title>Oh no!</title>
<Meta />
<Links />
</head>
<body>
<Error/>
<Scripts />
</body>
</html>
);
} |
@Kallyan01 i also have grammarly installed. i don't see anything in incognito window where all extensions are disabled. i'm wondering if this happens only on localhost or production applications face the same FOUC issue. |
Did you manage to fix it? |
@nilansaha Nope I think. It works well incognito. I think it was a development only error. |
What version of Remix are you using?
2.0.1
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Here is an mp4 of my staging site that is running remix v1 (with no streaming). as you can see, there is no flash of unstyled content, even though the route CSS is being reloaded on each page route:
redacted
and here is a video of my production site (running remix v2 with streaming) and most of the time, the page margins and paddings and widths are jumping after the CSS was reloaded and applied:
redacted
FWIW, I also observed this only happens in chromium browsers
Regardless of the site, my methods for CSS have remained the same:
Expected Behavior
No flash of unstyled content
Actual Behavior
flash of unstyled content
The text was updated successfully, but these errors were encountered: