export 'Redirect' (imported as 'Redirect') was not found in 'react-router-dom'

export 'Redirect' (imported as 'Redirect') was not found in 'react-router-dom'

Posted by Margie Crona on June 24, 2022

export 'Redirect' (imported as 'Redirect') was not found in 'react-router-dom'

export 'Redirect' (imported as 'Redirect') was not found in 'react-router-dom'

Posted by Margie Crona on June 24, 2022

If you come across this error in your React project:

export 'Redirect' (imported as 'Redirect') was not found in 'react-router-dom'

Your project has react-router-dom version 6. In version 6, you will need to replace component prop with element prop within your route

replace this:

<Redirect to={{pathname:'/dashboard'}}/>

with this:

<Navigate to={{pathname:'/dashboard'}}/>

or you can revert to react-router-dom version 5.

Hopefully this was helpful.