Hello guys, how are you all? Hope you all are fine. The other day I was learning react js and practicing some stuff. I faced the following error ‘Switch’ is not exported from ‘react-router-dom’ in reactjs. So, here I will explain you some possible solutions to get rid of this error.
Let's solve this error:
How To Solve ‘Switch’ is not exported from ‘react-router-dom’ Error ?
Solution-1: To solve 'Switch' is not exported from 'react-router-dom' error, just install Switch. Switch is replaced in react-router-dom version 6. So, you need to install react-router-dom version 5. Now, your error should be resolved.
Use the command below:
Solution-2: Use Routes instead of Switch.
Check the code below:
Then you can use it like this:
That's all about this issue. Hope your issue is resolved. Comment down which solution worked for you. Thankyou!