mui / material-ui

Material UI: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
https://mui.com/material-ui/
MIT License
92.46k stars 31.85k forks source link

[Migration] theme.spacing is not a function #42355

Open bhanu-vegrow opened 1 month ago

bhanu-vegrow commented 1 month ago

I've migrated from v4 to v5 and was previosuly using styled-components package, So made the adjustments of configuring @mui/styled-engine. Still I get error saying theme.spacing is not a function=>which is coming from makeStyles Cannot read properties of undefined (reading 'create')=>which also comes from "transition: theme.transitions.create('width'," in makeStyles. Maybe there might be some more errors because as AppLayout itself has encountered errors on these it's failing to run further. Basically theme is not configured properly I guess. How to configure styled-components and mui v5 to work smoothly?

updated dependencies versions:

"@mui/icons-material": "^5.15.18", "@mui/lab": "^5.0.0-alpha.170", "@mui/material": "^5.15.18", "@mui/styled-engine": "npm:@mui/styled-engine-sc@latest", "@mui/styled-engine-sc": "^6.0.0-alpha.18", "@mui/styles": "^5.15.18", "@mui/x-data-grid": "^7.5.0", "@mui/x-date-pickers": "^7.5.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.22.2", "styled-components": "^5.3.11", "resolutions": { "@mui/styled-engine": "npm:@mui/styled-engine-sc@latest" },

Search keywords:

bhanu-vegrow commented 1 month ago

It got resolved after running yarn install and yarn start, previously I was using npm i --force and npm run start

bhanu-vegrow commented 6 days ago

Want to understand the reason behind it? Why using yarn is not causing trouble but using npm install is having this issue? How it behave on prod environments? Can someone please look into it?

bhanu-vegrow commented 6 days ago

Closed it by mistake