TypeError : 'Component' cannot be used as JSX component
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP Wed Aug 25 23:20:18 UTC 2021 Binaries: Node: 14.18.2 npm: 8.3.0 Yarn: 1.22.17 pnpm: N/A Relevant packages: next: 12.1.6 react: 17.0.2 react-dom: 17.0.2
Which example does this report relate to?
with-redux
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I am using nextjs example with-redux . The current version of devDependencies @types/react
and @types/react-dom
gives type error Type Error 'Component' cannot be used as a JSX component.
Below is screenshot showing error
The problem can be solved by upgrading the @types/react
and @types/react-dom
dependencies
Expected Behavior
TypeError should not occur
To Reproduce
If you do not see the typeError after cloning this example repository run next build to see typeError while build process .
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Component cannot be used as a JSX component. Its return ...
Another common cause of the "Component cannot be used as a JSX component" error is when we return anything other ...
Read more >Component from NPM module cannot be used as a JSX ...
This is what the type error looks like: 'Component'(Name here) cannot be used as a JSX component. Its return type 'Element[]' is not...
Read more >[Solved] NPM package cannot be used as a JSX component
The NPM package cannot be used as a JSX component error occurs if you have installed multiple versions of @types/react package, ...
Read more >component cannot be used as a jsx component. - You.com
Component cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element. 79,182 Solution 1. A component...
Read more >Component cannot be used as a JSX component. Its return ...
[Solved]-Component cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element-Reactjs ... In case anyone is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This workaround is to add a resolution section to your
package.json
to ensure the correct TS defs were installed.You can change the above versions to which ever ones you’re using on your project.
I haven’t fully tested the above, but it seems to have worked for me on a quick test.
Upgrading these depencencies solves the issue :