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

Hydration Mismatch in Next.js #4557

Open
lblblong opened this issue Dec 24, 2024 · 3 comments
Open

Hydration Mismatch in Next.js #4557

lblblong opened this issue Dec 24, 2024 · 3 comments
Labels
status: waiting for author Issue with insufficient information

Comments

@lblblong
Copy link

lblblong commented Dec 24, 2024

Steps to reproduce

https://github.com/lblblong/nextjs-toolpad-demo

Current behavior

I am currently using the Toolpad library in a Next.js project (reproduction repository: nextjs-toolpad-demo). However, I am encountering a hydration mismatch error in the browser console. The error message is as follows:
image

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
    System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
  Binaries:
    Node: 18.19.1 - /run/user/1000/fnm_multishells/60963_1735054989551/bin/node
    npm: 10.2.4 - /run/user/1000/fnm_multishells/60963_1735054989551/bin/npm
    pnpm: 9.4.0 - /run/user/1000/fnm_multishells/60963_1735054989551/bin/pnpm
  Browsers:
    Chrome: Not Found
  npmPackages:
    @emotion/react: ^11.14.0 => 11.14.0 
    @emotion/styled: ^11.14.0 => 11.14.0 
    @mui/icons-material: ^6.3.0 => 6.3.0 
    @mui/material: ^6.3.0 => 6.3.0 
    @mui/material-nextjs: ^6.3.0 => 6.3.0 
    @toolpad/core: ^0.11.0 => 0.11.0 
    @types/react: ^19 => 19.0.2 
    react: ^19.0.0 => 19.0.0 
    react-dom: ^19.0.0 => 19.0.0 
    typescript: ^5 => 5.7.2 

Search keywords: Hydration mismatch next.js

@lblblong lblblong added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 24, 2024
@Dave4272-Office
Copy link

I also faced the same issue

for now the following solution helped me

<AppRouterCacheProvider
            options={{ enableCssLayer: true, key: "css", prepend: true }}
          >
    // Your Content Here
</AppRouterCacheProvider>

@lblblong
Copy link
Author

I also faced the same issue

for now the following solution helped me

<AppRouterCacheProvider
            options={{ enableCssLayer: true, key: "css", prepend: true }}
          >
    // Your Content Here
</AppRouterCacheProvider>

Thanks for sharing your solution. Unfortunately, it didn't work for me. I tried implementing the with the same options you mentioned, but it still didn't resolve the issue. If you have any other suggestions, please let me know. thx.

@bharatkashyap
Copy link
Member

Try adding data-toolpad-color-scheme="light" to the html tag at the root of the layout.tsx file to prevent this from happening. The error went away for me when doing it in the layout.tsx file in your reproduction repo.

@bharatkashyap bharatkashyap added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

3 participants