-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
Incompatability after MUI v6 update #1151
Comments
Update, I don't exactly understand why but this small change helps, wrapping the troublesome icon in a fragment: const toastHandler = (newToast: ReactElement | string, toastType: CustomToastTypes) => {
toast(newToast, {
type: toastType,
style: toastStyles[toastType].styles,
icon: () => toastStyles[toastType].icon,
closeButton: (
<>
<CloseOutlinedIcon
sx={{ color: theme.customPalette.textColors['Neutral/50'], fontSize: '16px' }}
/>
</>
),
});
}; |
I experienced same bug, I just downgraded will try again in the future. |
getting the same issue with v6 :( |
any known fixes here? |
In my case the solution was to remove theme from StyledAvatar const StyledAvatar = styled(MuiAvatar, .....)
.....
<StyledAvatar
variant={variant}
/*theme={theme} huh? */
color={color}
type={type}
size={size}
{...others}>
{children}
</StyledAvatar> It looks like |
It happens in createStyled.js, in the attachTheme method. It's also interesting that it's happening locally, but when I published it, no issues on production version. UPDATE: I tested locally (vite 5.4.3, latest MUI), definitely not working in debug mode (yarn run vite), but when I build and serve (vite build + vite serve) it's working without any issues |
Hi @rade-tomovic, did you manage to find a solution? |
It works, but I need a theme to control the colors. Overriding theme colors with hard-coded ones isn’t a clean solution for my case. I hope this issue gets resolved soon. |
I think the issue can be resolved (locally) if attachTheme function is updated inside node_modules/@mui/system/createStyled.js. const PROCESSED_PROPS = Symbol('mui.processed_props');
const processedPropsCache = new WeakMap();
function attachTheme(props, themeId, defaultTheme) {
try {
if (processedPropsCache.has(props)) {
return processedPropsCache.get(props);
}
const processedProps = {
...props,
theme: resolveTheme(themeId, props.theme, defaultTheme),
[PROCESSED_PROPS]: true // Mark as processed.
};
processedPropsCache.set(props, processedProps);
return processedProps;
} catch (error) {
console.error('Error in attachTheme:', error);
return props; // Return original props in case of error.
}
} I'm aware that it's not ideal, but it fixed similar issue for me where I forwarded theme as property to styled span |
Can we have some insider info whether this is a bug, or are we misusing some APIs? If it's not considered as a bug, then the recommended patches above could be potentially harmful even. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I use MUI Icon components within toasts, but after updating to MUI v6, I get a number of errors
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:
I can't replicate easily in Codepen, but can provide context. My Toast wrapper code looks like:
What is the expected behavior?
Previously this worked perfectly well, and now I see errors:
TypeError: Cannot add property Symbol(mui.processed_props), object is not extensible at attachTheme (chunk-NNS653BL.js?v=980847ca:7278:26)
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 18 on Chromium
The text was updated successfully, but these errors were encountered: