Open kavitakadam297 opened 2 years ago
The way that I got around this is to got to your package.json and change your "react-router-dom" version to "^5.2.3". React changed the way that the Router work and got rid of Switch. Unfortunately it isn't as simple as just renaming Switch to the new Routes
I switched the version of "react-router-dom" but im still getting an error. Anyone know why?
So basically, react-router-dom updated and changed a lot of the way you work with the package. You have two options, upgrade and use the new package and make the changes to your code, or use the older version. Obviously I have no idea which version you're using so I can't help but if you down to upgrade here's some resources:
Here's what your component tree should look like, replacing Switch with Routes and making all the changes:
https://reactrouter.com/docs/en/v6/getting-started/overview#configuring-routes
Using useHistory and .push? Try this, it uses Link and useNavigate
https://reactrouter.com/docs/en/v6/getting-started/overview#navigation
Getting the params from the route? Try this, it uses "useParams" hook:
https://reactrouter.com/docs/en/v6/getting-started/overview#reading-url-parameters
switch is not exported or usehistory not imported from react-router-dom. please help me