-
-
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
[base] components
-> slots
API rename
#34693
[base] components
-> slots
API rename
#34693
Conversation
@material-ui/core: parsed: +0.24% , gzip: +0.38% |
871b7e8
to
166f967
Compare
166f967
to
62ee608
Compare
4579059
to
9f49020
Compare
@michaldudak what do you think about accompanying this change with a codemod? It shouldn't be complicated to be written considering we have similar codemods. We could target all imports in Another idea for making the transition easier will be to warn in the components if some of the old props are used. |
Sure, I can try writing one. However, it won't cover (userland) components built on top of Base components, so it may give a false sense of security.
We can do this in Material UI as both old and new APIs will be used in parallel. I wouldn't do this immediately after introducing the new API, though. Let's create a gentler introduction in the docs first and then, closer to deprecation we can have a warning. |
The overall changes look good to me. Are you going to add the codemod in this PR or in a separate one? |
I'll create it in this PR. |
@@ -63,25 +63,21 @@ The code snippet below shows how to override the root element of the [`BadgeUnst | |||
``` | |||
|
|||
:::warning | |||
If the root slot is customized with both the `component` and `components` props, then `component` will take precedence. | |||
If the root slot is customized with both the `component` and `slots` props, then `component` will take precedence. |
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.
This name change makes statements like this so much easier to understand! 🙌
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.
Docs look great! I think these concepts are much easier to grasp as a result of these changes, and it's clear right away when you see the differences in the docs.
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.
👍 The codemod looks good to me.
As discussed in #33416 and #34080, this PR:
components
prop toslots
componentsProps
prop toslotProps
slots
' fields from Pascal-case to camelCase (Root
->root
)The above changes were implemented only in MUI Base.
In cases where a Base component is used in a Material UI component (Badge, Modal, Popper, Slider), the new props were added to the Material UI code and alongside the old ones, so that there are no breaking changes in the stable package.
Breaking change
components
andcomponentsProps
props in Base components toslots
andslotProps
, respectively.slots
' fields to camelCaseThere is a codemod that can help to deal with the breaking changes.
It will rename the props of unstyled components. However, if there are any custom components wrapping the Base ones, their props won't be affected by the codemod and must by renamed manually.
Run the following command to execute the codemod:
cc @flaviendelangle