asChild without exactly one element child

shadcn/as-child-single-elementerrorreactcorrectness

Why it matters

Slot clones a single child; text, fragments or several children throw React.Children.only.

Fix

Wrap the children in one element.

Credit

  • From Radix UI

    asChild requires exactly one child element that receives the merged props.

References