react-checkbox-tree
react-checkbox-tree copied to clipboard
Anyone getting this error? 'CheckboxTree' cannot be used as a JSX component
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
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