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-ui/core incompatible with next.js #15505

Closed
2 tasks done
jaycenhorton opened this issue Apr 27, 2019 · 6 comments
Closed
2 tasks done

@material-ui/core incompatible with next.js #15505

jaycenhorton opened this issue Apr 27, 2019 · 6 comments
Labels
external dependency Blocked by external dependency, we can’t do anything about it

Comments

@jaycenhorton
Copy link

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

When using next.js versions >= 8.0.5-canary.11 I am not able to use certain components of @material-ui/core@3.9.3. If I downgrade to @material-ui/core@3.3.0 there is no issue.

On the flip side, I can use next.js versions <= 8.0.5-canary.10 with @material-ui/core@3.9.3 (and proabably any other version)

The issue appears to only happen when I import and use a ListItem, though It's possible others have the same issue.

this seems to be the same issue but was closed

Additional notes:

Expected Behavior 🤔

I should be able to build and start an app using a <ListItem> import and use the latest versions of next.js when using material-ui

Current Behavior 😯

I get a 500 error with the following output in the console:

TypeError: Cannot read property 'dense' of undefined                                                                                                                                                                                              
    at Object.children (/home/ubuntu/dev/mui-next/node_modules/@material-ui/core/ListItem/MergeListContext.js:27:31)                                                                                                                              
    at a.render (/home/ubuntu/dev/mui-next/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:64)
    at a.read (/home/ubuntu/dev/mui-next/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:58)
    at renderToString (/home/ubuntu/dev/mui-next/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:83)
    at render (/home/ubuntu/dev/mui-next/node_modules/next-server/dist/server/render.js:83:16)
    at renderPage (/home/ubuntu/dev/mui-next/node_modules/next-server/dist/server/render.js:201:20)
    at Function.value (/home/ubuntu/dev/mui-next/.next/server/static/NF5o8EJCIiIS3Bbj1tDFL/pages/_document.js:808:41)
    at Object.loadGetInitialProps (/home/ubuntu/dev/mui-next/node_modules/next-server/dist/lib/utils.js:42:35)
    at Object.renderToHTML (/home/ubuntu/dev/mui-next/node_modules/next-server/dist/server/render.js:207:36)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Steps to Reproduce 🕹

Link: https://codesandbox.io/s/nrnx4p6q4p

repo: https://github.com/jaycenhorton/next-mui-errors

Context 🔦

Your Environment 🌎

Tech Version
Material-UI ^ v3.9.3
React 16.8.6
next ^ 8.0.5-canary.11
jaycenhorton added a commit to jaycenhorton/material-ui that referenced this issue Apr 27, 2019
@joshwooding
Copy link
Member

Is this issue present using the 4.0.0 alphas?

@oliviertassinari oliviertassinari added the external dependency Blocked by external dependency, we can’t do anything about it label Apr 27, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 27, 2019

@jaycenhorton It shouldn't be an issue with Material-UI the list context has a default value: {}. The problem is fixed in v4.0.0-alpha.8. I can't explain what's wrong in v3 😱.

@oliviertassinari
Copy link
Member

It seems to be a regression on Next.js side. next 8.0.4 works, next 8.1.0 doesn't.

@oliviertassinari
Copy link
Member

Let's track it in vercel/next.js#7167.

@thesambayo
Copy link

Please, I am confused as to how to solve this problem "TypeError: Cannot read property 'dense' of undefined" in my code. I did not get how you guys solved it. It still occured in my code this morning

@oliviertassinari
Copy link
Member

@samuelkurdz I believe you need to revert back to v8.0.4: https://github.com/zeit/next.js/releases/tag/v8.0.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external dependency Blocked by external dependency, we can’t do anything about it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants