ui icon indicating copy to clipboard operation
ui copied to clipboard

Tabs component does not work with @types/[email protected]

Open lukeberry99 opened this issue 1 year ago • 4 comments

Hi, I've just upgraded my project from Next 13 to Next 14 and this involved bumping my react and react types from 18.2.20 to 18.2.33 and this has broken the tabs with the below error:

1. 'Tabs' cannot be used as a JSX component.
     Its type 'ForwardRefExoticComponent<TabsProps & RefAttributes<HTMLDivElement>>' is not a valid JSX element type.
       Type 'ForwardRefExoticComponent<TabsProps & RefAttributes<HTMLDivElement>>' is not assignable to type '(props: any, deprecatedLegacyContext?: any) => ReactNode'.
         Type 'import("/[...]/node_modules/@radix-ui/react-slot/node_modules/@types/react/index").ReactNode' is not assignable to type 'React.ReactNode'.
           Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
             Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'. [2786]

lukeberry99 avatar Oct 30 '23 14:10 lukeberry99

Hi! I had the same problem in a button component and I was able to fix it adding this to the component. I added a closing tag so that children can be assigned to the element and the property is no longer missing. I clicked the line referring to the code position in the error so that I could find the component that needed to be modified I'm not sure if it's the best approach but it worked in my case

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
  ({ className, variant, size, asChild = false, ...props }, ref) => {
    const Comp = asChild ? Slot : "button"
    return (
      <Comp
        className={cn(buttonVariants({ variant, size, className }))}
        ref={ref}
        {...props}
      >
      // I added a closing tag
      </Comp>
    )
  }
)

TobysNap avatar Oct 31 '23 05:10 TobysNap

+1 Having this issue as well.

SamHep0803 avatar Nov 01 '23 05:11 SamHep0803

+1 Same issue on the button component

thisislvca avatar Nov 03 '23 09:11 thisislvca

Solved:

  • https://github.com/shadcn-ui/ui/issues/1978#issuecomment-1873574838

ImBIOS avatar Jan 02 '24 02:01 ImBIOS

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Feb 13 '24 23:02 shadcn