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 in React 19 with Pigment CSS and MuiSvgIcon fontSize prop #44675

Open
wh5938316 opened this issue Dec 6, 2024 · 6 comments · May be fixed by mui/pigment-css#364
Open

Hydration Error in React 19 with Pigment CSS and MuiSvgIcon fontSize prop #44675

wh5938316 opened this issue Dec 6, 2024 · 6 comments · May be fixed by mui/pigment-css#364
Assignees
Labels
package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@wh5938316
Copy link

wh5938316 commented Dec 6, 2024

Steps to reproduce

Steps:

  1. Update to React 19.
  2. Update to Next 15.
  3. Use Pigment CSS alongside MUI.
  4. Override the MuiSvgIcon component’s variants.fontSize.small in the custom theme.
export default withPigment(nextConfig, {
  theme: createTheme({
    cssVariables: true,
    components: {
      MuiSvgIcon: {
        styleOverrides: {
          root: {
            fill: 'currentColor',
            color: 'inherit',
            variants: [
              {
                props: {
                  fontSize: 'small',
                },
                style: {
                  fontSize: '1rem',
                },
              },
            ],
          },
        },
      },
    }
  }),
  transformLibraries: ['@mui/material'],
});
  1. Set the fontSize prop on an MuiSvgIcon component in the app.
<SvgIcon fontSize="small">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
    <path d="M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z" />
  </svg>
</SvgIcon>

Current behavior

No response

Expected behavior

image

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: pigment-css, react19, next15, hydration error

@wh5938316 wh5938316 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 6, 2024
@mj12albert
Copy link
Member

@wh5938316 Would you mind providing a repro in codesandbox or stackblitz?

@mj12albert mj12albert 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 7, 2024
@wh5938316
Copy link
Author

wh5938316 commented Dec 7, 2024

@wh5938316 Would you mind providing a repro in codesandbox or stackblitz?

@mj12albert
here is codesandbox link
the github repo

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Dec 7, 2024
@zannager zannager added the package: material-ui Specific to @mui/material label Dec 10, 2024
@DiegoAndai DiegoAndai assigned brijeshb42 and unassigned mj12albert Dec 12, 2024
@DiegoAndai
Copy link
Member

@brijeshb42 may I ask you to identify if this is on Pigment CSS or Material UI side?

@wh5938316
Copy link
Author

@brijeshb42 @DiegoAndai Hi, Is there any progress on this issue?

@brijeshb42
Copy link
Contributor

Hey. It went out of my radar. I'll check this today and get back.

@brijeshb42
Copy link
Contributor

brijeshb42 commented Jan 9, 2025

I have not been able to debug the cause of this issue. The main location where it's supposed to tell the difference in the className attribute, it cuts off to ellipsis.
s1jwuyke s1jwuyke-15 MuiSvgIcon-root MuiSvgIcon-fontSizeSmall s1jwuyke-3 ...

I checked both the server and the client rendered classNames and found both to be same though which is also validated by the prod build having the same classnames

s1jwuyke s1jwuyke-15 MuiSvgIcon-root MuiSvgIcon-fontSizeSmall s1jwuyke-3 s1jwuyke-14 s1jwuyke-16.

Update:

I found that the code generated for server side is different from the one generated for client side. Debugging more.

brijeshb42 pushed a commit to brijeshb42/pigment-css that referenced this issue Jan 9, 2025
This was mutating the original theme object resulting in different codes
for server and client components.

Fixes: mui/material-ui#44675
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants