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

[Masonry] Error: Attempted to call unstable_generateUtilityClasses() #39946

Closed
2 tasks done
nocodehummel opened this issue Nov 21, 2023 · 5 comments
Closed
2 tasks done
Labels
component: masonry This is the name of the generic UI component, not the React module! nextjs package: lab Specific to @mui/lab

Comments

@nocodehummel
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example: https://github.com/nordicgit70/nextjs-app

Steps:

  1. Next.js template with MUI packages.
  2. Copied Masonry SSR sample.
  3. Open browser to localhost renders the error.

Current behavior 😯

Masonry component renders an error message as React-server-component in Nextjs 14.0.2 App.

Error: Attempted to call unstable_generateUtilityClasses() from the server but unstable_generateUtilityClasses is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.

Expected behavior 🤔

Expected to render sample Masonry.

Context 🔦

The error is (re-)produced in Next.js template App.

Your environment 🌎

npx @mui/envinfo
System:
    OS: Windows 11 10.0.22621
    Browser: Firefox
  Binaries:
    Node: 18.18.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Chromium (119.0.2151.72)
  npmPackages:
    @emotion/react: ^11.11.1 => 11.11.1
    @emotion/styled: ^11.11.0 => 11.11.0
    @mui/base:  5.0.0-beta.24
    @mui/core-downloads-tracker:  5.14.18
    @mui/lab: ^5.0.0-alpha.153 => 5.0.0-alpha.153
    @mui/material: ^5.14.18 => 5.14.18
    @mui/private-theming:  5.14.18
    @mui/styled-engine:  5.14.18
    @mui/system:  5.14.18
    @mui/types:  7.2.9
    @mui/utils:  5.14.18
    @types/react: 18.2.18 => 18.2.18
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0```
</details>
@nocodehummel nocodehummel added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 21, 2023
@mj12albert mj12albert added component: masonry This is the name of the generic UI component, not the React module! nextjs package: lab Specific to @mui/lab and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 21, 2023
@mj12albert
Copy link
Member

@nordicgit70 We haven't added 'use client' to lab components, to get Masonry to work you would need to wrap it in a client component first

@nocodehummel
Copy link
Author

Your documentation has a sample Masonry for SSR. SSR means without use client.

@nocodehummel
Copy link
Author

nocodehummel commented Nov 21, 2023

@mj12albert linked #32688 which indicates that SSR is working with following dependencies.

"dependencies": {
    "@emotion/react": "^11.9.0",
    "@emotion/styled": "^11.8.1",
    "@mui/icons-material": "^5.6.2",
    "@mui/lab": "^5.0.0-alpha.80",
    "@mui/material": "^5.6.4",
    "next": "12.1.6",
    "react": "18.1.0",
    "react-dom": "18.1.0"
  },```

@mj12albert
Copy link
Member

SSR means without use client.

@nordicgit70 This is actually incorrect and a common misunderstanding of RSCs - Client Components can still be rendered to static HTML on the server (SSR), see this explanation by the React team/working group for more details: reactwg/server-components#4

@nocodehummel
Copy link
Author

Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: masonry This is the name of the generic UI component, not the React module! nextjs package: lab Specific to @mui/lab
Projects
None yet
Development

No branches or pull requests

2 participants