I encountered the same problem with "react-router-dom": "6.0.0-beta.0"
and after researching, I found the hint in node_modules/react-router/README.md
.
If you're using React Router, you should never `import` anything directly from
the `react-router` package, but you should have everything you need in either
`react-router-dom` or `react-router-native`. Both of those packages re-export
everything from `react-router`.
If you'd like to extend React Router and you know what you're doing, you should
add `react-router` **as a peer dependency, not a regular dependency** in your
package.
thus I did add to package.json
"peerDependencies": {
"react-router": "6.0.0-beta.0"
},
and run npm i
from the terminal to make the change effective.
You may also need to disable eslint as it still complains in my case and fail the CI/CD pipeline.
// eslint-disable-next-line import/named
import {PartialRouteObject} from 'react-router'
At the time of writing, it's worth noting that you may upgrade to the latest version of react-router v6.3
and get away with this issue. But in our case, we can't since there are a few features working in v6.0.0-beta.0 that v6.3 can't still deliver, such as https://github.com/remix-run/react-router/issues/8139
Hope it helps. Happy coding!