jakezatecky / react-checkbox-tree

A simple and elegant checkbox tree for React.
https://jakezatecky.github.io/react-checkbox-tree/
MIT License
709 stars 211 forks source link

Anyone getting this error? 'CheckboxTree' cannot be used as a JSX component #502

Open ariscruz opened 5 months ago

ariscruz commented 5 months ago

Full error: 'CheckboxTree' cannot be used as a JSX component. Its instance type 'CheckboxTree' is not a valid JSX element. The types returned by 'render()' are incompatible between these types. Type 'React.ReactNode' is not assignable to type 'import Type '{}' is not assignable to type 'ReactNode'

Some details: react-checkbox-tree: "1.8.0" react: "^17.0.2" react-dom: "^17.0.2" react-types: "^17.0.37"

We're using yarn to build. Tried to downgrade react-checkbox-tree to "1.7.3" but same error.

Have looked into adding a resolutions for @types/react to 17 (similar to this: https://github.com/facebook/react/issues/24304#issuecomment-1094551986), did a cleanup of node_modules and then yarn install but error still persists

Updating to react18 is not an option yet. Appreciate your help. Thanks

ariscruz commented 5 months ago

Able to solve the error by adding this in tsconfig.json under compilerOptions

"paths": { "react": [ "./node_modules/@types/react" ] }

based from this SO link: https://stackoverflow.com/questions/71841181/some-components-cannot-be-used-as-a-jsx-component

If there's a better way to solve this, let me know. Thanks