Type error: 'SimpleBar' cannot be used as a JSX component.
See original GitHub issueI am getting an error during the NextJS build process like in below:
Type error: 'SimpleBar' cannot be used as a JSX component.
I am using ^2.3.6 as simplebar-react version.
How can I fix this?
Issue Analytics
- State:
- Created a year ago
- Reactions:16
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Component cannot be used as a JSX component in React
The error Component cannot be used as a JSX component occurs for multiple reasons, returning an array of JSX elements instead of a...
Read more >Component cannot be used as a JSX component. Its return ...
js to App.tsx, I met the same error for component named Section. The solution for me was a component type React.Fc<{...}> ...
Read more >Component from NPM module cannot be used as a JSX ...
Its return type 'Element[]' is not a valid JSX element. ... otherwise an error wouldn't be thrown because React allows an array to...
Read more >simplebar-react - npm
React component for SimpleBar. Latest version: 2.4.3, last published: 3 months ago. Start using simplebar-react in your project by running ...
Read more >'SVG' cannot be used as a JSX component.
Its instance type 'InlineSVG' is not a valid JSX element. The types returned by 'render()' are incompatible between these types. Type 'React.ReactNode' 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 Free
Top 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
Here’s a workaround for people looking for a solution: I installed react-beautiful-dnd and also got the same error:
I managed to track the error and this dependency introduced types for react in v18. For context, I’m using Typescript with React 17 since I have some dependencies that are not fully compatible with v18. This is the command output:
Now the only thing to be done is to override this dependency when installing. In npm is done by forcing the dependency version in the
overrides
section in the package.json file. I’m using yarn v1 so the directive is calledresolutions
:After modifying the package.json file and running
yarn install
, I restarted VS Code and the error is now gone.It worked