Skip to content

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

smeng9
Copy link
Contributor

@smeng9 smeng9 commented Apr 17, 2025

Copy link
Collaborator

@djhi djhi left a 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

@smeng9
Copy link
Contributor Author

Hi @djhi,

Suggestions applied

Comment on lines +55 to +60
sx={[
{
alignItems: 'flex-start',
},
...(Array.isArray(rest.sx) ? rest.sx : [rest.sx]),
]}
Copy link
Collaborator

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:

Suggested change
sx={[
{
alignItems: 'flex-start',
},
...(Array.isArray(rest.sx) ? rest.sx : [rest.sx]),
]}
sx={{
alignItems: 'flex-start',
...rest.sx,
}}

Copy link
Contributor Author

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

Comment on lines +10 to +18
sx={[
{
flex: '1',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
},
...(Array.isArray(props.sx) ? props.sx : [props.sx]),
]}
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Comment on lines +72 to +78
sx={[
{
py: 2,
textAlign: 'center',
},
...(Array.isArray(sx) ? sx : [sx]),
]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

@smeng9smeng9 requested a review from djhi April 23, 2025 08:18
@smeng9smeng9 changed the base branch from next to master May 2, 2025 01:34
@smeng9
Copy link
Contributor Author

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

Sign up for free to join this conversation on . Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants