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
[IconButton] Custom color causes TypeError #33054
Comments
|
The customization capability is not complete. I marked this as an enhancement. The fix can use optional chaining like in createTheme({
components: {
MuiIconButton: {
root: ({ ownerState, theme }) => ({
...ownerState.color === 'textPrimary' && {
// your style
}
})
}
}
}) |
Ah that explains it. I worked around it by passing the color to the icon component instead: <IconButton>
<CloseIcon color="textPrimary" />
</IconButton> |
|
Is this issue open to working on? |
|
@Shubhamchinda I don't think it's being worked on, so feel free to take it. Thank you! |
Great, thanks. I'll take this. |
|
Any progress? Would love to implement this PR |
@geraldaddey Give me a day, and I'll submit a PR. |
Duplicates
Latest version
Current behavior😯
When I augment
IconButtonwith new colors:and then try to use these colors:
My app crashes with:
at the following location:
material-ui/packages/mui-material/src/IconButton/IconButton.js
Line 78 in dec32b3
Expected behavior🤔
IconButtondoesn't throw TypeError when using custom color. Instead it handles it likeSvgIcondoes:material-ui/packages/mui-material/src/SvgIcon/SvgIcon.js
Line 54 in dec32b3
Steps to reproduce🕹
No response
Context🔦
No response
Your environment🌎
No response
The text was updated successfully, but these errors were encountered: