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

New noSsr prop of ThemeProvider throws warning #44576

Open
bc-m opened this issue Nov 27, 2024 · 4 comments · May be fixed by #44624
Open

New noSsr prop of ThemeProvider throws warning #44576

bc-m opened this issue Nov 27, 2024 · 4 comments · May be fixed by #44624
Assignees
Labels
dx Related to developers' experience package: system Specific to @mui/system

Comments

@bc-m
Copy link
Contributor

bc-m commented Nov 27, 2024

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/react-yeet9i?file=Demo.tsx
  2. Look into console

Current behavior

Console warning:

Warning: Failed prop type: The following props are not supported: `noSsr`. Please remove them.
at ThemeProvider (https://react-yeet9i.stackblitz.io/turbo_modules/@mui/[email protected]/ThemeProvider/ThemeProvider.js:55:5)
at ThemeProviderNoVars (https://react-yeet9i.stackblitz.io/turbo_modules/@mui/[email protected]/node/styles/ThemeProviderNoVars.js:15:10)
at ThemeProvider (https://react-yeet9i.stackblitz.io/turbo_modules/@mui/[email protected]/node/styles/ThemeProvider.js:16:3)
at BasicButtons
at StyledEngineProvider (https://react-yeet9i.stackblitz.io/turbo_modules/@mui/[email protected]/node/StyledEngineProvider/StyledEngineProvider.js:56:5)

Expected behavior

No console warning.

Context

Release of v6.1.9 adds new noSsr prop for ThemeProvider: https://github.com/mui/material-ui/releases/tag/v6.1.9

#44451

Your environment

npx @mui/envinfo

Google Chrome Version 131.0.6778.86 (Offizieller Build) (arm64)

  System:
    OS: macOS 15.1.1
  Binaries:
    Node: 22.11.0 - /usr/local/bin/node
    npm: 10.9.0 - /usr/local/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 131.0.6778.86
    Edge: Not Found
    Safari: 18.1.1
  npmPackages:
    @emotion/react: 11.13.5 => 11.13.5 
    @emotion/styled: ^11.13.5 => 11.13.5 
    @mui/core-downloads-tracker:  6.1.9 
    @mui/icons-material: ^6.1.9 => 6.1.9 
    @mui/material: ^6.1.9 => 6.1.9 
    @mui/private-theming:  6.1.9 
    @mui/styled-engine:  6.1.9 
    @mui/system: ^6.1.9 => 6.1.9 
    @mui/types:  7.2.19 
    @mui/utils:  6.1.9 
    @mui/x-date-pickers: ^7.22.3 => 7.22.3 
    @mui/x-internals:  7.21.0 
    @types/react: ^18.3.12 => 18.3.12 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^5.7.2 => 5.7.2 

Search keywords: ThemeProvider noSsr

@bc-m bc-m added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 27, 2024
@bc-m bc-m changed the title New noSsr prop of ThemeProvider not working New noSsr prop of ThemeProvider throws warning Nov 27, 2024
@oliviertassinari oliviertassinari added the package: system Specific to @mui/system label Nov 27, 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 Nov 28, 2024
@siriwatknp
Copy link
Member

Based on the docs, noSsr should be used when you have both light and dark color schemes:

<ThemeProvider theme={createTheme({ colorSchemes: { dark: true }})} noSsr>
  <Button variant="text">Text {console.log('render')}</Button>
</ThemeProvider>

There is no error with the above code.

@siriwatknp
Copy link
Member

May be a warning about using noSsr would help?

@siriwatknp siriwatknp added dx Related to developers' experience and removed bug 🐛 Something doesn't work labels Nov 28, 2024
@DiegoAndai
Copy link
Member

DiegoAndai commented Nov 29, 2024

@siriwatknp where's the warning coming from? I would expect proptypes to accept this:

@siriwatknp
Copy link
Member

@siriwatknp where's the warning coming from? I would expect proptypes to accept this:

I think the warning is correct.

image

The internal ThemeProviderNoVars does not accept noSsr. The author is using noSsr incorrectly. I think we could improve the DX by warning that noSsr can be used when you create a theme with light and dark color schemes.

What do you think?

@siriwatknp siriwatknp linked a pull request Dec 2, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dx Related to developers' experience package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants