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

I have followed the documentation for setting up an Okta Sign-In Widget in React: https://developer.okta.com/code/react/okta_react_sign-in_widget/

I am getting the error "Failed to compile.

./src/Login.js
Attempted import error: ‘Redirect’ is not exported from ‘react-router-dom’.".

My decencies are as followed:
“dependencies”: {
@okta/okta-auth-js”: “^4.5.1”,
@okta/okta-react”: “^4.1.0”,
@okta/okta-signin-widget”: “^5.2.1”,
@testing-library/jest-dom”: “^5.11.8”,
@testing-library/react”: “^11.2.2”,
@testing-library/user-event”: “^12.6.0”,
“history”: “^5.0.0”,
“react”: “^17.0.1”,
“react-dom”: “^17.0.1”,
“react-router-dom”: “^6.0.0-beta.0”,
“react-scripts”: “4.0.1”,
“web-vitals”: “^0.2.4”
},

I suspect it is because the 'Redirectcomponent has been removed from thereact-router-dom` version 6.

Is there a way around this?

Thank you in advance!!

Hi @gman,

There is a draft PR in okta-react repo to handle the react-router-6.0 update.

Okta is watching the official release of react-router-6.0, and will actively working on a release when it’s available on npm. Relevant docs and samples would be updated too.

Would you be able to use react-router-dom 5.2.0 until then ?

Thanks!

1 Like

Thank you for your quick response.

No problem, my project is now working fine with a previous version of react-router-dom.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.