-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[scheduler] Remove unnecessary useMemo usages #20133
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: master
Are you sure you want to change the base?
[scheduler] Remove unnecessary useMemo usages #20133
Conversation
|
Deploy preview: https://deploy-preview-20133--material-ui-x.netlify.app/ Bundle size report
|
| const dropTargetRef = useDayCellDropTarget({ value, addPropertiesToDroppedEvent }); | ||
|
|
||
| const props = React.useMemo(() => ({ role: 'gridcell' }), []); | ||
| const props = { role: 'gridcell' }; |
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 saw components on Base UI (e.g PreviewCardBackdrop) where we just inline the props object inside useRenderElement() instead of creating a props variable before.
No strong preference here 👍
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 was wondering the same, I wasn't sure if it helps with readability. If the props object grows I would prefer to have it in a separate object to not pollute the useRenderElement call. But in these cases it's probably the same. Up to what you prefer, as you will be reading this code more often :) cc @mui/explore
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 will leave this for future refactor, for now, let's just remove the unneeded useMemos.
This PR removes unnecessary usages of useMemo over props that are passes in the
useRenderElementhook.Example usage:
The
useRenderElementhook will more or less conver the call toso there is no need for memoization. On the opposite side, memoizing would just add more overhead. The transformation should also improve readability as a bonus.