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 error using nextjs turbopack and icons-material #44055

Open
FabianRueckert opened this issue Oct 9, 2024 · 5 comments · May be fixed by #43264
Open

Hydration error using nextjs turbopack and icons-material #44055

FabianRueckert opened this issue Oct 9, 2024 · 5 comments · May be fixed by #43264
Assignees
Labels
bug 🐛 Something doesn't work nextjs package: icons Specific to @mui/icons

Comments

@FabianRueckert
Copy link

FabianRueckert commented Oct 9, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/devbox/elegant-alex-xrjs5l

Steps:

  1. Check out the example from https://github.com/mui/material-ui/tree/master/examples/material-ui-nextjs-pages-router-ts
  2. Add an icon from @mui/icons-material to index.ts
  3. Start with turbopack with next dev --turbo
  4. See error in the console
    image

Related to #34905

Current behavior

Hydration Error:

Warning: Prop `className` did not match. Server: "MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1umw9bq-MuiSvgIcon-root" Client: "MuiSvgIcon-root MuiSvgIcon-fontSizeMedium mui-4uxqju-MuiSvgIcon-root"
index.js:8 Warning: Prop `className` did not match. Server: "MuiSvgIcon-root MuiSvgIcon-fontSizeMedium  css-20bmp1-MuiSvgIcon-root" Client: "MuiSvgIcon-root MuiSvgIcon-fontSizeMedium  mui-1slccg-MuiSvgIcon-root"
    at svg
    at https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:1020:141
    at SvgIcon (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:6461:180)
    at RefreshIcon
    at div
    at https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:1020:141
    at Box (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:12397:162)
    at div
    at https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:1020:141
    at Container (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:10685:23)
    at Home
    at DefaultPropsProvider (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:11525:11)
    at RtlProvider (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:10829:11)
    at ThemeProvider (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:15567:13)
    at ThemeProvider (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:11631:13)
    at CssVarsProvider (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:11729:17)
    at ThemeProvider (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:4262:11)
    at AppCacheProvider (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:13350:11)
    at MyApp (https://xrjs5l-3000.csb.app/_next/static/chunks/pages__app_tsx_035eb2._.js:22:13)
    at PathnameContextProviderAdapter (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:25194:11)
    at ErrorBoundary (https://xrjs5l-3000.csb.app/_next/static/chunks/%5Bnext%5D_overlay_client_ts_eac06c._.js:6040:1)
    at ReactDevOverlay (https://xrjs5l-3000.csb.app/_next/static/chunks/%5Bnext%5D_overlay_client_ts_eac06c._.js:6266:11)
    at Container (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:26292:1)
    at AppContainer (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:26375:11)
    at Root (https://xrjs5l-3000.csb.app/_next/static/chunks/node_modules_975935._.js:26524:11)

Expected behavior

No hydration error.

Context

Trying to run NextJS with MUI and turbopack.

Your environment

See codesandbox

Search keywords: nextjs hydration error mui icons turbopack

@FabianRueckert FabianRueckert added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 9, 2024
@DiegoAndai
Copy link
Member

@siriwatknp may I ask you to take a look at this one?

@zannager zannager added package: icons Specific to @mui/icons nextjs labels Oct 10, 2024
@DiegoAndai DiegoAndai moved this to Backlog in Material UI Oct 14, 2024
@siriwatknp siriwatknp added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 21, 2024
@siriwatknp siriwatknp moved this from Backlog to Selected in Material UI Oct 21, 2024
@siriwatknp
Copy link
Member

siriwatknp commented Oct 23, 2024

It's related to package manager from what I've tried but not sure what's the root cause.

with yarn 1.22.19 + --turbo

with pnpm 9.12.2 + --turbo

However, without using --turbo, everything works just fine.

cc @Janpot do you know what might be the root cause of this?

The error seems to be that the icons does not use the cache from the custom CacheProvider in @mui/material-nextjs, very much like it's using a different version or there are duplicated of instances.

@Janpot
Copy link
Member

Janpot commented Oct 23, 2024

@siriwatknp can you try with the codesandbox builds of #43264 (all @mui packages)

@siriwatknp
Copy link
Member

@siriwatknp can you try with the codesandbox builds of #43264 (all @mui packages)

Awesome, it works with yarn and pnpm.

@DiegoAndai
Copy link
Member

@siriwatknp @Janpot so this one will be fixed by #43264? Is there a workaround we can provide in the meantime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work nextjs package: icons Specific to @mui/icons
Projects
Status: Selected
Development

Successfully merging a pull request may close this issue.

5 participants