-
-
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
The component
prop is not allowed on a styled()
MUI component
#37551
Comments
component
is not allowed in a styled
MUI componentcomponent
prop is not allowed on a styled()
MUI component
There is a silly workaround: - const StyledTypography = styled(Typography)({ ... });
+ const StyledTypography = styled(Typography)<{ component: string }>({ ... }); So basically forcing the |
I need to dig deeper into it to have more context around the cc: @siriwatknp You might have more details. |
If I pass |
This issue is not just limited to
Both |
I'll check and revert. |
@chouclee You're correct. It's removing all the system props from the component after being styled. I faced the same issue while creating a design system. Cannot override global settings always, need to create wrapper kinds of components several times. We need to have this issue resolved. |
I have a similar issue to this, but instead of |
FWIW, I think this seems to work for styled:
https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop |
also, seems to be ok for this as well:
|
a few storybook stories to prove it out a bit:
not great IMO, I really with the composition docs had a code example to do both ref forwarding and accept generics. The same behavior is desired with |
Duplicate of #29875 |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/strange-hofstadter-6668qh?file=/src/App.tsx
Observe the Typescript error.
Current behavior 😯
The typings cause an error, saying
component
doesn't exist on thestyled()
MUI component, but it does exist on the same MUI component directly. Somehow the typings for that one prop is not transferred over properly to the typings of the output of thestyled()
function.It does work, though with that typescript error.
Expected behavior 🤔
No error. I don't see why this prop wouldn't be allowed, especially given that it works perfectly fine at runtime.
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
I'm on Firefox 114. Not that it matters.
The text was updated successfully, but these errors were encountered: