-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Updating from v5 to v6 doesnt work: createStyled.js:26 Uncaught TypeError: Cannot assign to read only property 'theme' of object '#<Object>' #44343
Comments
I think the error came from using a styled component and passing the theme to it and the theme was imported from the theme file (createTheme({}) |
Hey @BennyAlex, thanks for the report! Could you provide a minimal reproduction? This would help a lot. A repo sharing your project would be perfect. Thank you! |
I have the same issue here with a component. Exact same error message after upgrading to v6.
Is there any upgrade guidance for who use styled? Any tools out there that can validate our stylings? |
Hey @visualjeff, thanks for the report! Could you provide a minimal reproduction? This would help a lot. A live example would be perfect. A repo or a StackBlitz sandbox would work. Thank you! |
I think I figured out our issue while creating repro code. Don't pass the theme down as a prop so you can use it to style a component.
|
thats what I also wrote here I think the error came from using a styled component and passing the theme to it and the theme was imported from the theme file (createTheme({}) so thats basically the solution to remove the theme prop from styled components |
So I think we can close the issue. |
@BennyAlex so I understand you were able to solve the issue on your side as well? |
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information. |
i just ending the migration from v4 to v6 and faced the same issue but it didn't come from |
and i think the reason is like @BennyAlex said when you trying to insert the theme and when you take the global theme and use it inside the styled component the scop theme is trying to override the global theme and the global theme is a frozen object and then you get this error TypeError |
Steps to reproduce
I am trying to upgrade to v6 and also used the codemods but I am seeing this error.
Current behavior
No response
Expected behavior
No response
Context
No response
Your environment
npx @mui/envinfo
Search keywords: 'theme' of object, reateStyled.js:26
The text was updated successfully, but these errors were encountered: