Skip to content

Component cannot be used as a JSX component #432

Open
@DerekChan65535

Description

@DerekChan65535

I have got an error on create-react-app project with the latest core UI.

How to reproduce:

  1. Create default react ts sandbox.
  2. Add "@coreui/coreui": "^5.3.2", "@coreui/react": "^5.5.0", to package.json.
  3. Use CButton in the App.tsx

Got compile error:

'CButton' cannot be used as a JSX component.
  Its return type 'ReactNode' is not a valid JSX element.
    Type 'undefined' is not assignable to type 'Element | null'.typescript(2786)

https://codesandbox.io/p/sandbox/jr4t78?file=%2Fsrc%2FApp.tsx%3A9%2C8

Image

Activity

mrholek

mrholek commented on Apr 29, 2025

@mrholek
Member

@DeckerCHAN, which version of @types/react do you use?

DerekChan65535

DerekChan65535 commented on Apr 29, 2025

@DerekChan65535
Author

@mrholek here

  "devDependencies": {
    "@types/react": "18.2.38",
    "@types/react-dom": "18.2.15",
    "typescript": "4.4.4"
  },
mrholek

mrholek commented on Apr 29, 2025

@mrholek
Member

Please try to update to the latest version.

DerekChan65535

DerekChan65535 commented on Apr 30, 2025

@DerekChan65535
Author

After adding ^ to all the versions, the problem is still there.

  "dependencies": {
    "loader-utils": "^3.2.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "^5.0.1",
    "@coreui/coreui": "^5.3.2",
    "@coreui/react": "^5.5.0"
  },
  "devDependencies": {
    "@types/react": "^18.2.38",
    "@types/react-dom": "^18.2.15",
    "typescript": "^4.4.4"
  },

Even using all the latest won't fix the issue😔 :

  "dependencies": {
    "loader-utils": "latest",
    "react": "latest",
    "react-dom": "latest",
    "react-scripts": "latest",
    "@coreui/coreui": "latest",
    "@coreui/react": "latest"
  },
  "devDependencies": {
    "@types/react": "latest",
    "@types/react-dom": "latest",
    "typescript": "latest"
  },

You can take a look at here

DerekChan65535

DerekChan65535 commented on May 5, 2025

@DerekChan65535
Author

@mrholek Any updates on this are much appreciated.

mrholek

mrholek commented on May 6, 2025

@mrholek
Member

Please update @coreui/react to v5.6.0 and

"@types/prop-types": "15.7.14",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Component cannot be used as a JSX component · Issue #432 · coreui/coreui-react