Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[material-ui][Autocomplete] Grouped options demo has console errors in Next.js #39474

Closed
MSturges opened this issue Oct 16, 2023 · 4 comments · Fixed by #39795
Closed

[material-ui][Autocomplete] Grouped options demo has console errors in Next.js #39474

MSturges opened this issue Oct 16, 2023 · 4 comments · Fixed by #39795
Assignees
Labels
component: autocomplete This is the name of the generic UI component, not the React module! nextjs package: material-ui Specific to @mui/material typescript

Comments

@MSturges
Copy link

MSturges commented Oct 16, 2023

Steps to reproduce 🕹

Link to live example: https://mui.com/material-ui/react-autocomplete/#grouped

using nextjs

It works but I see this in my console

app-index.js:31 Warning: A props object containing a "key" prop is being spread into JSX:
  let props = {key: someKey, tabIndex: ..., role: ..., id: ..., onMouseMove: ..., onClick: ..., onTouchStart: ..., data-option-index: ..., aria-disabled: ..., aria-selected: ..., className: ..., children: ...};
  <li {...props} />
React keys must be passed directly to JSX without using spread:
  let props = {tabIndex: ..., role: ..., id: ..., onMouseMove: ..., onClick: ..., onTouchStart: ..., data-option-index: ..., aria-disabled: ..., aria-selected: ..., className: ..., children: ...};
  <li key={someKey} {...props} />
    at Autocomplete (webpack-internal:///(app-pages-browser)/../../node_modules/@mui/material/Autocomplete/Autocomplete.js:405:83)
    at RenderGroup

Current behavior 😯

No response

Expected behavior 🤔

No response

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@MSturges MSturges added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 16, 2023
@DiegoAndai DiegoAndai changed the title Autocomplete Grouped is bug [material-ui][Autocomplete] Grouped example is bugged Oct 16, 2023
@DiegoAndai DiegoAndai added package: material-ui Specific to @mui/material component: autocomplete This is the name of the generic UI component, not the React module! labels Oct 16, 2023
@mj12albert
Copy link
Member

mj12albert commented Oct 17, 2023

@MSturges Could you share a repro? I couldn't reproduce this in a sandbox: https://codesandbox.io/p/sandbox/https-github-com-mui-material-ui-issues-39474-kdgq9g?file=%2Fsrc%2Fapp%2Fpage.tsx%3A28%2C2 (it's that exact demo copy+pasted into a Next.js setup without modification)

@HaoboZ
Copy link

HaoboZ commented Oct 21, 2023

@MSturges Could you share a repro? I couldn't reproduce this in a sandbox: https://codesandbox.io/p/sandbox/https-github-com-mui-material-ui-issues-39474-kdgq9g?file=%2Fsrc%2Fapp%2Fpage.tsx%3A28%2C2 (it's that exact demo copy+pasted into a Next.js setup without modification)

I'm seeing this as well on my project and on the codesandbox you linked. It only shows up once you open the autocomplete

@digibake
Copy link

digibake commented Nov 3, 2023

Hi,

Yes I'm seeing the warning as well. Here's a screenshot of the error as it appears in Chrome developer tools console

Screenshot 2023-11-03 at 10 51 33

@mj12albert
Copy link
Member

Next.js doesn't like the key prop being spread: vercel/next.js#55642

I've opened a PR for the fix, sandbox: https://codesandbox.io/p/sandbox/https-github-com-mui-material-ui-pull-39795-fwdm7f?file=%2Fsrc%2Fapp%2Fpage.tsx%3A1%2C1

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! nextjs package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants