react-daisyui icon indicating copy to clipboard operation
react-daisyui copied to clipboard

Dropdown.Item with NavLink

Open redxzeta opened this issue 2 years ago • 3 comments

Using NavLink from react-router-dom with <DropDown.Item>, I would get this in the console

<a> cannot appear as a descendant of <a>.

Wondering if there's a way to use NavLink and DropDown.Item

Workaround:

  <li>
    <NavLink to={route}>{name}</NavLink>
  </li>

redxzeta avatar Jun 26 '22 16:06 redxzeta

Ah, yeah that will be a problem since the DropdownItem renders an anchor. Let me see what I can do about that, and post a PR here!

benjitrosch avatar Jun 27 '22 14:06 benjitrosch

The workaround you mentioned sounds like a viable solution to me. The Daisyui docs for the dropdown shows the usage of the li><a>Item 1</a></li> strategy. The only thing react-daisyui does is wrapping that and exposing it as the Dropdown.Item static.

My suggestion would be to leave it as is and maybe have an example story about it.

What do y'all think?

Klaas058 avatar Sep 19 '22 08:09 Klaas058

Wouldn't a polymorphic prop be ideal in this case?

Edit: Sorry, I just realized this has already been mentioned in #129 and #108. I believe these 3 issues are related and could be solved if such a prop would be implemented. I can take a look into this and see if I can come up with a solution. Would that be okay? @benjitrosch

dev0T avatar Apr 05 '23 21:04 dev0T