react 拖拽库 react-dragable 报 TS2786: 'DraggableCore' cannot be used as a JSX component.
作者:互联网
TS2786: 'DraggableCore' cannot be used as a JSX component. Its instance type 'DraggableCore' 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("/home/ifnk/node_modules/@types/react/index").ReactNode'. Type '{}' is not assignable to type 'ReactNode'.
一开始 用 stackoverflow 的这个方法
"resolutions":{
"@types/react": "17.0.0", // or "16.9.27"
"@types/react-dom": "17.0.9"
},
没有解决
去 github issue 搜索了一下 https://github.com/react-grid-layout/react-draggable/issues/652
项目 能起来 了 ,先 暂时 这样写吧
import { DraggableCore } from 'react-draggable';
const DraggableCore1: any = DraggableCore;
<DraggableCore1/>
标签:TS2786,used,component,DraggableCore,react,type,types 来源: https://www.cnblogs.com/ifnk/p/16554461.html