Skip to content

Tabs components cannot be used as JSX components due to type errors #8650

@MukulAppDev

Description

@MukulAppDev

Provide a general summary of the issue here

I'm upgrading to the latest version of @adobe/react-spectrum and encountering several TypeScript errors when using the TabList and TabPanels components. This seems to be due to improper return types in the library’s type definitions, similar to previous issues reported with DismissButton and OverlayProvider in React Aria.

🤔 Expected Behavior?

There should be no type errors when using TabList and TabPanels components as JSX elements in React with TypeScript.

😯 Current Behavior

'TabList' cannot be used as a JSX component.
  Its return type 'ReactNode' is not a valid JSX element.
    Type 'string' is not assignable to type 'ReactElement<any, any>'.
'TabPanels' cannot be used as a JSX component.
  Its return type 'ReactNode' is not a valid JSX element.
    Type 'string' is not assignable to type 'ReactElement<any, any>'.

💁 Possible Solution

The return types of TabList and TabPanels should be updated from ReactNode to ReactElement.

🔦 Context

The issue mirrors a previously reported problem in the react-aria repo where DismissButton and OverlayProvider had incorrect return types. Tabs were not included in that fix 8099 .

🖥️ Steps to Reproduce

  1. Install and use @adobe/react-spectrum
  2. Try to render the TabList and TabPanels components as JSX
  3. Observe the TypeScript errors
`'TabList' cannot be used as a JSX component.
  Its return type 'ReactNode' is not a valid JSX element.
    Type 'string' is not assignable to type 'ReactElement<any, any>'.
'TabPanels' cannot be used as a JSX component.
  Its return type 'ReactNode' is not a valid JSX element.
    Type 'string' is not assignable to type 'ReactElement<any, any>'.
`

Version

3.43.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

MAC OS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions