- Notifications
You must be signed in to change notification settings - Fork 5.4k
Deprecate system props #10680
New issue
Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.
By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on ? Sign in to your account
base: master
Are you sure you want to change the base?
Deprecate system props #10680
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! However:
- The CRM and the simple examples still use MUI v5 and shouldn't be modified
- Our packages uses MUIv5 too in dev to ensure we don't use MUIv6 or v7 only features. That means our stories shouldn't be modified either
Please revert those changes
071fd19
to 931f74e
Compare Hi @djhi, Suggestions applied |
sx={[ | ||
{ | ||
alignItems: 'flex-start', | ||
}, | ||
...(Array.isArray(rest.sx) ? rest.sx : [rest.sx]), | ||
]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this: why not just:
sx={[ | |
{ | |
alignItems: 'flex-start', | |
}, | |
...(Array.isArray(rest.sx) ? rest.sx : [rest.sx]), | |
]} | |
sx={{ | |
alignItems: 'flex-start', | |
...rest.sx, | |
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @djhi,
These are auto applied by the codemod tool in https://mui.com/material-ui/migration/migrating-from-deprecated-apis/#system-props.
Main reason we did not directly unpack ...rest.sx, but we converted to an array is because the typing of SxProp can also be functions. MUI suggests using array values. https://mui.com/system/getting-started/the-sx-prop/#array-values
sx={[ | ||
{ | ||
flex: '1', | ||
textOverflow: 'ellipsis', | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
}, | ||
...(Array.isArray(props.sx) ? props.sx : [props.sx]), | ||
]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, do we really need the Array check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, SxProps can be functions, which we cannot directly unpack
sx={[ | ||
{ | ||
py: 2, | ||
textAlign: 'center', | ||
}, | ||
...(Array.isArray(sx) ? sx : [sx]), | ||
]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment
Hi @djhi do you have additional questions regarding array check for sx prop? The codemod for original mui upgrade is here mui/material-ui#42282 |
Problem
The system props is deprecated in v6 https://mui.com/material-ui/migration/migrating-from-deprecated-apis/#system-props and v7 https://mui.com/material-ui/migration/upgrade-to-v7/#quality-of-life-improvements
Follow up of #10463