Skip to content
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 no theme (zero-config ThemeProvider, Next 14, not Cloudflare) #237

Open
jamesvclements opened this issue Nov 24, 2023 · 1 comment

Comments

@jamesvclements
Copy link

I'm having some trouble debugging why I'm seeing a flash of no theme on oldfriends.studio. I see this only in production. Here's a video of the issue:

Old.Friends.Engineering.Studio-Friday-November-24-2023-10.28.48AM.mp4

You can see that there's a brief moment where the html tag has the theme injected, then it loses the attributes, then they kick back in. In that moment between, it flashes the white background, which is the default in CSS. It should use my system default of dark.

My providers.tsx:

New Issue · pacocourseynext-themes-Friday-November-24-2023-10 56 55AM@2x

The top of my root layout.tsx:

New Issue · pacocourseynext-themes-Friday-November-24-2023-10 57 23AM@2x

This site does allow the user to setTheme, but this is only called inside an onClick handler, so I don't think that should be effecting initial visits. I recorded the video when pulling up the site for the first time in an incognito window.

@1111mp
Copy link

1111mp commented Nov 27, 2023

When I use next-intl and nextui, switching languages causes flickering.

  • "next-intl": "^3.1.4"
  • "next-themes": "^0.2.1"
Screen.Recording.2023-11-28.at.01.36.47.mov

There is a chance that flickering will not occur.

when change language:

const onSelectChange: React.ChangeEventHandler<HTMLSelectElement> = (
    event,
  ) => {
    const nextLocale = event.target.value;
    startTransition(() => {
      router.replace(pathname, { locale: nextLocale });
    });
  };

https://github.com/1111mp/next-temp-app This is the code repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants