Had the same issue.
Just add this
"resolutions": {
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2"
},
to package.json
file and run yarn
command.
UPD: Just a bit detailed answer:
@types/react-dom
has its own dependencies and one of them is @types/react
with a version set to '*'
– a major release, that now, probably, refers to 18
.
Even if you specify some strict versions in your package.json
(without ^
) parent package might install its own duplicates of packages that you are already using for its own purposes.
By using resolutions
we are specifying strict restrictions for dependencies of dependencies.