Component cannot be used as a JSX component
I have got an error on create-react-app project with the latest core UI.
How to reproduce:
- Create default react ts sandbox.
- Add
"@coreui/coreui": "^5.3.2", "@coreui/react": "^5.5.0",to package.json. - Use
CButtonin theApp.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
@DeckerCHAN, which version of @types/react do you use?
@mrholek here
"devDependencies": {
"@types/react": "18.2.38",
"@types/react-dom": "18.2.15",
"typescript": "4.4.4"
},
Please try to update to the latest version.
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
@mrholek Any updates on this are much appreciated.
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",
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