reactjsfrontendweb-deployment-project

Error importing Switch when using create-react app


Image of the Error shown

I really do not know how to resolve this issue. I need help...

the Error states; "export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' (possib:

I can't create a link tag in react due to this error. I do need help with this...

the error is cleared anytime I remove the switch tag but the link doesn't still work.


Solution

  • In react-router-dom v6, Switch is replaced by Routes. You need to update the import from

    import { Switch, Route } from "react-router-dom";
    

    to

    import { Routes ,Route } from 'react-router-dom';
    

    react-router-v6