I use the newest version of shadcn for developing. Now I want to use the Button as the menu trigger.

<NavigationMenuTrigger asChild>
  <Button variant="outline">
    <CircleUserRound></CircleUserRound>test
  </Button>       
</NavigationMenuTrigger>

I always get the following error:

Unhandled Runtime Error

Error: React.Children.only expected to receive a single React element child.

But there is only the button an child, there are not multiple children. How can I fix this?

I tried to find answer via the search engine and inspected other code parts of working code.

1

There are 1 best solutions below

0
Wraithy On

you have two "children" in button.. use fragment for that

<NavigationMenuTrigger asChild>
  <Button variant="outline">
    <><CircleUserRound></CircleUserRound>test</>
  </Button>       
</NavigationMenuTrigger>