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

Inconsistent theming when the page loads #243

Closed
Sachinv220 opened this issue Dec 16, 2023 · 3 comments
Closed

Inconsistent theming when the page loads #243

Sachinv220 opened this issue Dec 16, 2023 · 3 comments

Comments

@Sachinv220
Copy link

I want to invert the colours of an image when the theme is light, this is the code.

export function DarkImage({ ...props }: ImageProps) {
  const { theme } = useTheme();

  if (theme === "dark") {
    return <Image {...props} className="filter invert" />;
  } else {
    return <Image {...props} />;
  }
}

but when the page loads there is inconsistent, but when I toggle theme it works fine. Is there a problem with next-theme or Nextjs 14.

@Sachinv220
Copy link
Author

Sachinv220 commented Dec 16, 2023

This is the https://github.com/Sachinv220/chat/tree/ui the above code is only present in the ui branch.

The files that would be related to the current issue are
src/components/Logo.tsx
src/app/page.tsx
src/app/layout.tsx

@PixeledCode
Copy link

Could be related to Hydration Mismtach
Also there is higher chance of getting help if you create a reproducible on CodeSandBox

@Sachinv220
Copy link
Author

Thank You,I will take a look.

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