Attempted import error: 'withRouter' is not exported from 'react-router-dom'

I have already downgraded react-router-dom to version 5.0.1 which is what ionic/react-router indicates as a dependency but I sill get the error. Do I need to go to an even earlier version?

I’ve got Ionic React v5 and the v6 rc-3 both working with react-router 5.1.2 and react-router-dom 5.1.2.

Are you using Typescript? And which react-dom are you using?

I’m using the latest version of TypeScript (4.3.5), but Ionic will also work with TypeScript 3.

react-dom is 17.0.2.

You definitely have a configuration issue; Ionic React requires react-router 5, not 6, but other than that, it should work with the latest versions of all dependencies.

I figured out my problem, I think. I am not using TS so I am not using any of the @types modules. Works fine with TS, won’t work with JS. Guess it’s time to give in and start using TS.

1 Like