react-beautiful-dnd
react-beautiful-dnd copied to clipboard
Builtin package @types/react is not works
'DragDropContext' cannot be used as a JSX component
TS2786: 'DragDropContext' cannot be used as a JSX component.
Its instance type 'DragDropContext' 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("path/node_modules/@types/hoist-non-react-statics/node_modules/@types/react/index").ReactNode'.
72 | }
73 |
> 74 | return <DragDropContext onDragEnd={onDragEnd} >
| ^^^^^^^^^^^^^^^
75 | <Droppable
76 | droppableId={dropIdWithPrefix.current}
77 | direction={direction}
{
"devDependencies": {
"@types/react": "17.0.30",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/react-dom": "^17.0.14",
"typescript": "^4.6.2"
},
"dependencies": {
"react": "^17.0.2",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^17.0.2"
},
"resolutions": {
"@types/react": "17.0.30"
}
}
It will install @types/react, so use the "resolutions" constraint version, but it is still invalid。

npm i
Got the same problem on existing project. Tried to delete node_modules and reinstall. Nothing helped.
Then created a project from scratch with npx create-react-app proj --template typescript
- and it worked with same set of deps.
Got the same problem upgrading @types/react
from 17 to 18. Solved by deleting my node modules directory and lockfile and reinstalling.
rm -rf node_modules
rm yarn.lock
yarn install