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

Popover not setting 'key' prop internally #3305

Closed
yashwason opened this issue Jun 20, 2024 · 1 comment
Closed

Popover not setting 'key' prop internally #3305

yashwason opened this issue Jun 20, 2024 · 1 comment

Comments

@yashwason
Copy link

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v2.0.4

What browser are you using?

Chrome 126.0.6478.62

Reproduction URL

https://codesandbox.io/p/sandbox/headless-ui-react-popover-missing-keys-74z5yc

Describe your issue

It seems that HeadlessUI's Popover does not set keys somewhere internally. React throws a warning in the browser console; you may confirm this in the Sandbox itself.

@thecrypticace
Copy link
Contributor

Hey — you need to set a key on your Fragment. Instead of this:

  {menuLinks.map((link) => (
    <>
      <a key={link.href + link.linkText} href={link.href}>
        {link.linkText}
      </a>
    </>
  ))}

You want this:

  {menuLinks.map((link) => (
    <Fragment key={link.href + link.linkText}>
      <a href={link.href}>
        {link.linkText}
      </a>
    </Fragment>
  ))}

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants