-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Box] Error when using component property in a styled Box component after upgrading to 5.14.3 #38274
Comments
Thanks for the report. This behavior is unfortunate but consistent with all the other components in Material UI. We'll try to find a fix for all the components (likely within the const StyledBox = styled(Box)(() => ({
fontSize: "100px",
color: "white"
})) as typeof Box; cc @brijeshb42, @mnajdova |
Thank you for your feedback. As this seems to be a breaking change, should it not be part a a major release and not be hidden in a patch release? |
@michaldudak Using wildcard |
@doberkofler We were unaware that this use case would break, so it was not done intentionally. If we don't find the solution until the next release (early next week), we'll revert the PR that caused the problem. |
@michaldudak I understand. Thank you for caring! |
What should be the workaround if i also pass some extra props to styled component? export const StyledBox = styled(Box)<{ size?: number }>`
width: ${(p) => p.size}px;
height: ${(p) => p.size}px;
` as typeof ???; UPD export const StyledBox = styled(Box)<{ size?: number }>`
width: ${(p) => p.size}px;
height: ${(p) => p.size}px;
` as React.FC<BoxProps & { size?: number; component?: React.ElementType }>; |
We are going to revert the commit the caused these breaking changes. Expect a release with the fix today or tomorrow. |
The exact same thing is still breaking with MenuItem using @mui/material@5.14.4, do you want a separate bug or is it still a variation of this one? https://codesandbox.io/s/great-wildflower-pr8hdy?file=/Demo.tsx |
@ggascoigne, this is a different issue. It wasn't caused by the same recent changes, but it was not supported in Material UI v5 (and possibly before). See #29875 |
OK thank you. That said, it's worked well until 5.14.4 and it seems weird to say that it's not supported when the underlying JavaScript clearly supports it, it's useful, and only the types are wrong. Either way, I can work around it. |
Thanks for saving my day @michaldudak . Works with Joy UI as well. |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example:
https://codesandbox.io/s/old-sky-jvvldp?file=/Demo.tsx:266-275
Steps:
The use of the component property reports an error
Current behavior 😯
After upgrading to 5.14.3 TypeScript reports the following type error:
Expected behavior 🤔
No type error as with 5.14.1
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: