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

[material-pigment-css] Grid throws an error when it is RSC #43635

Closed
kevinpfox opened this issue Sep 6, 2024 · 4 comments · Fixed by mui/pigment-css#233
Closed

[material-pigment-css] Grid throws an error when it is RSC #43635

kevinpfox opened this issue Sep 6, 2024 · 4 comments · Fixed by mui/pigment-css#233
Assignees
Labels
bug 🐛 Something doesn't work component: Grid The React component. examples Relating to /examples package: material-ui Specific to @mui/material package: pigment-css Specific to @pigment-css/*

Comments

@kevinpfox
Copy link

kevinpfox commented Sep 6, 2024

Steps to reproduce

Link to live example:
https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-pigment-css-nextjs-ts?file=README.md

This is the same StackBlitz example provided here: https://github.com/mui/material-ui/tree/master/examples/material-ui-pigment-css-nextjs-ts

Steps:

  1. Attempt to use https://github.com/mui/material-ui/tree/master/examples/material-ui-pigment-css-nextjs-ts
  2. See it hit the following error when running sample files locally... ⨯ Error: Cannot access default.muiName on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
    at stringify ()
    at stringify ()
    at stringify ()
    at stringify ()

Current behavior

⨯ Error: Cannot access default.muiName on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
at stringify ()
at stringify ()
at stringify ()
at stringify ()

Expected behavior

Render the page

Context

I've tried this on a mac, local environment and get the same result.
I added "use client" to top of /src/app/page.tsx to force it to render the page. I assume this should not be necessary.

Your environment

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

Out of the box

ss03

Hack to make page work

ss04

Search keywords: Demo - Material UI Pigment CSS Next.js App Router example in TypeScript

@kevinpfox kevinpfox added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 6, 2024
@kevinpfox kevinpfox changed the title This example is not working "out of the box" - https://github.com/mui/material-ui/tree/master/examples/material-ui-pigment-css-nextjs-ts Example is not working: https://github.com/mui/material-ui/tree/master/examples/material-ui-pigment-css-nextjs-ts Sep 6, 2024
@stunaz
Copy link
Contributor

stunaz commented Sep 7, 2024

had this issue,
the problem is with the Grid Component
by using import Grid from '@mui/material/Grid2'; it will also work

@kevinpfox
Copy link
Author

kevinpfox commented Sep 7, 2024

You are onto something. Thank you for replying.

Doing the following swap out in /src/app/page.tsx ...makes it work again.

//import Grid from '@mui/material-pigment-css/Grid';
import Grid from '@mui/material/Grid2';

@oliviertassinari oliviertassinari added the examples Relating to /examples label Sep 8, 2024
@siriwatknp siriwatknp added bug 🐛 Something doesn't work package: pigment-css Specific to @pigment-css/* package: material-ui Specific to @mui/material component: Grid The React component. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 10, 2024
@siriwatknp siriwatknp changed the title Example is not working: https://github.com/mui/material-ui/tree/master/examples/material-ui-pigment-css-nextjs-ts [material-pigment-css] Grid throws an error when it is RSC Sep 12, 2024
@siriwatknp
Copy link
Member

The root cause is the isGridComponent(child) in the Pigment CSS Grid. The error occurs when the child of a Grid is a client component.

I think the hotfix is to check for container check first and then apply the isGridComponent(child).

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

We value your feedback @kevinpfox! How was your experience with our support team?
If you could spare a moment, we'd love to hear your thoughts in this brief Support Satisfaction survey. Your insights help us improve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: Grid The React component. examples Relating to /examples package: material-ui Specific to @mui/material package: pigment-css Specific to @pigment-css/*
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants