Attempted import error: 'Switch' is not exported from 'react-router-dom'
@lebyy▲ 0 net votes
Problem: I don't know why I am getting this error and I can't find an answer for it anywhere. I have uninstalled the react-router-dom package and reinstalled it, but it continues to tell me that the switch module is not exported from react-router-dom. Here's my code.… Fix (from the top answer): In react-router-dom v6, "Switch" is replaced by routes "Routes". You need to update the import from import { Switch, Route } from "react-router-dom"; to import { Routes ,Route } from 'react-router-dom'; You also need to update the Route declaration from <Route path="/" component={Home} /> to <Route path='/'…