-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[material-ui] Fix slotProps.transition
types
#45214
base: master
Are you sure you want to change the base?
Conversation
slotProps.transition
types
Netlify deploy previewhttps://deploy-preview-45214--material-ui.netlify.app/ Bundle size report |
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.
Looks good. Left a question. I'll let @DiegoAndai do another pass.
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 also closes #40650 👍🏼. @siriwatknp I assigned you to it and added it to the description. Please review it.
This change makes the children
optional, but from what I remember, some components will throw if no children are provided. May I ask you to make sure that none of these components will crash if no children are provided? Otherwise, we have to either:
- Make the children required
- Modify the components so they can handle this case
For #40650, I added a comment here.
Do you mean the I am not sure where this PR changes the behavior, can you point me to the code? |
transition: React.JSXElementConstructor< | ||
TransitionProps & { children?: React.ReactElement<unknown, any> } | ||
>; |
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.
any slot should be React.ElementType
, otherwise user cannot provide their own props interface.
See this TS playground
I agree with your comment 👌🏼
You're right One final question: In the test files, we're using const transitionProps =
typeof slotProps?.transition === 'function'
? slotProps.transition(ownerState)
: slotProps?.transition; Should we use the |
I don't think |
@siriwatknp I didn't mean modifying What I propose is to use |
closes #45210
closes #40650
Root cause
The existing slotProps below for transition is not correct:
It's because
TransitionProps
extendsReact.HTMLAttributes<HTMLElement>
that causes the final types to be a union ofTransitionProps
and HTML props. That's whytransition['onExited']
does not exist, see this TypeScript playgroundThis PR fixes the issue by moving
TransitionProps
to the second parameter (theTOverrides
).All
slotProps.transition
should follow: