bsidelinger912 / react-tooltip-lite

MIT License
78 stars 38 forks source link

Typescript error: 'Tooltip' cannot be used as a JSX component. #128

Closed hallee9000 closed 2 years ago

hallee9000 commented 2 years ago

I got this error:

'Tooltip' cannot be used as a JSX component.
  Its instance type 'Tooltip' 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("/Users/leadream/figma/heron-transfer-plugin/node_modules/@types/react-dom/node_modules/@types/react/index").ReactNode'.
        Type '{}' is not assignable to type 'ReactNode'.ts(2786)

My dependencies:

"react": "16.8.0",
"react-dom": "16.8.0",
"typescript": "^4.6.3",

tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "outDir": "dist",
    "jsx": "react",
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": false,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
  },
  "include": ["src/**/*", "react-tooltip-lite/dist/index.d.ts", "typings.d.ts", "node_modules/@types/**/*", "node_modules/@figma/**/*"]
}

Any solutions?

magnattic commented 2 years ago

This usually happens when you have multiple incompatible versions of @types/react or @types/react-dom installed. You could use yarn resolutions or npm overrides to force a certain version across all your deps.

hallee9000 commented 2 years ago

This usually happens when you have multiple incompatible versions of @types/react or @types/react-dom installed. You could use yarn resolutions or npm overrides to force a certain version across all your deps.

Thanks @magnattic . Add this in package.json solved it.

image