mongodb-developer / mern-stack-example

Mern Stack code for the Mern Tutorial
Apache License 2.0
292 stars 261 forks source link

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

Closed tabishmazhar closed 2 years ago

tabishmazhar commented 2 years ago

Hi, getting this issue:

./src/components/edit.js Attempted import error: 'withRouter' is not exported from 'react-router'.

I noticed package.json on a new project does not contain the following line: "react-router-dom": "^5.2.0", I guess this means if you follow instructions as per the blog: https://www.mongodb.com/languages/mern-stack-tutorial it does not uses the latest version.

I therefore made the code exactly like code files on Github but still getting this issue, please advise.

JiaJun8899 commented 2 years ago

In your client folder run this in the terminal npm i react-router-dom@5.2

ZarNizza commented 2 years ago

Hi, Support! Thanks for detailed tutorial! But... Please, keep the training article and examples up to date and update the dependencies. If you do everything according to the article - your example does not work today - Router requires a wrapper and "withRouter" is no longer supported - the Edit doesn't work. And, please, tell the beginners that at the first start the database is empty and there are no records of "Richard" and "Billy" there. ))) Thank you for your efforts!

Pash10g commented 2 years ago

Hi @tabishmazhar and @ZarNizza ,

Thanks for reporting this. I will work on updating the code and migrating it to the newest version.

Meanwhile, I will fix the version of react-router-dom to 5.2.1 as a temporary workaround.

Regards, Pash

Pash10g commented 2 years ago

PR #15 fixed this issue