Skip to content
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

[autocomplete] Avoid spread operator #40968

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/mui-material/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ const Autocomplete = React.forwardRef(function Autocomplete(inProps, ref) {

const renderGroup = renderGroupProp || defaultRenderGroup;
const defaultRenderOption = (props2, option) => {
const { key, ...otherProps } = props2;
// Need to clearly apply key because of https://github.com/vercel/next.js/issues/55642
return (
<li key={key} {...otherProps}>
<li {...props2} key={props2.key}>
Comment on lines +557 to +559
Copy link
Contributor

Choose a reason for hiding this comment

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

I've read the issue but I still can't wrap my head around what the cause is.

And yeah from a performance POV, using the spread operator is always bad, so for leaf elements it can be better to not use it. An easy escape hatch when one is simply transfering props could be to use directly React.createElement('li', props2, children).

{getOptionLabel(option)}
</li>
);
Expand Down
Loading