coreui-react icon indicating copy to clipboard operation
coreui-react copied to clipboard

Component cannot be used as a JSX component

Open DerekChan65535 opened this issue 10 months ago • 6 comments

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

DerekChan65535 avatar Apr 27 '25 16:04 DerekChan65535

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

mrholek avatar Apr 29 '25 16:04 mrholek

@mrholek here

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

DerekChan65535 avatar Apr 29 '25 23:04 DerekChan65535

Please try to update to the latest version.

mrholek avatar Apr 29 '25 23:04 mrholek

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 avatar Apr 30 '25 01:04 DerekChan65535

@mrholek Any updates on this are much appreciated.

DerekChan65535 avatar May 05 '25 09:05 DerekChan65535

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",

mrholek avatar May 06 '25 07:05 mrholek

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Jul 05 '25 14:07 github-actions[bot]