-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
[pickers] Use the new ownerState
in <PickersCalendarHeader />
, <PickersArrowSwitcher />
and <DayCalendarSkeleton />
#15499
[pickers] Use the new ownerState
in <PickersCalendarHeader />
, <PickersArrowSwitcher />
and <DayCalendarSkeleton />
#15499
Conversation
Deploy preview: https://deploy-preview-15499--material-ui-x.netlify.app/ |
…owSwitcher and DayCalendarSkeleton
fd4865a
to
5c9341e
Compare
<DayCalendarSkeletonDay | ||
key={index2} | ||
variant="circular" | ||
width={DAY_SIZE} | ||
height={DAY_SIZE} | ||
className={classes.daySkeleton} | ||
ownerState={{ day }} | ||
data-day-in-month={dayInMonth} |
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 can create a DayCalendarSkeletonOwnerState
but the component is probably not used a lot and even less overriden with styleOverrides
so I went with simplicity here
|
||
export type SlideDirection = 'right' | 'left'; | ||
|
||
interface PickerSlideTransitionOwnerState extends PickerOwnerState { |
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.
It is not used in any styleOverrides
, only in useUtilityClasses
but I'm also unifying the parameters of this hook
...ickers/src/internals/components/PickersArrowSwitcher/describes.PickersArrowSwitcher.test.tsx
Outdated
Show resolved
Hide resolved
ownerState
in PickersCalendarHeader
, PickersArrowSwitcher
and DayCalendarSkeleton
ownerState
in <PickersCalendarHeader />
, <PickersArrowSwitcher />
and <DayCalendarSkeleton />
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 ... just a small suggestion that might apply to other areas as well ... not blocking!
const { ownerState: pickerOwnerState } = usePickerPrivateContext(); | ||
const ownerState = { ...pickerOwnerState, slideDirection }; | ||
const classes = useUtilityClasses(classesProp, ownerState); |
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.
very small performance thing: would it make sense here to prevent creating 2 additional objects?
const { ownerState: pickerOwnerState } = usePickerPrivateContext(); | |
const ownerState = { ...pickerOwnerState, slideDirection }; | |
const classes = useUtilityClasses(classesProp, ownerState); | |
const classes = useUtilityClasses(classesProp, { | |
...usePickerPrivateContext().ownerState, | |
slideDirection, | |
}); |
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.
For me we have the exact same amount of objects created with both approaches.
We only skip the creation of the pickerOwnerState and
ownerState` variables (which are reference based since it's an object so for me it's negligeable)
…PickersArrowSwitcher />` and `<DayCalendarSkeleton />` (mui#15499)
Part of #14475