Skip to content

Component cannot be used as a JSX component #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DeckerCHAN opened this issue Apr 27, 2025 · 4 comments
Open

Component cannot be used as a JSX component #432

DeckerCHAN opened this issue Apr 27, 2025 · 4 comments

Comments

@DeckerCHAN
Copy link

DeckerCHAN commented Apr 27, 2025

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

@mrholek
Copy link
Member

mrholek commented Apr 29, 2025

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

@DeckerCHAN
Copy link
Author

@mrholek here

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

@mrholek
Copy link
Member

mrholek commented Apr 29, 2025

Please try to update to the latest version.

@DeckerCHAN
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants