'Export 'Switch' was not found in react-router-dom
how can i solve this problem Compiled with problems:
ERROR in ./src/App.js 20:37-43
export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' (possible exports: BrowserRouter, HashRouter, Link, MemoryRouter, NavLink, Navigate, NavigationType, Outlet, Route, Router, Routes, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createPath, createRoutesFromChildren, createSearchParams, generatePath, matchPath, matchRoutes, parsePath, renderMatches, resolvePath, unstable_HistoryRouter, useHref, useInRouterContext, useLinkClickHandler, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams)
I want help to solve this problem
Solution 1:[1]
Checkout the new version of react-router-dom. Switch has been replaced with Routes and some other things have been changed too. https://reactrouter.com/docs/en/v6/getting-started/overview
Solution 2:[2]
If you are using react-router-dom version V6.0.0 then it will not work, so downgrade the version of the react-router-dom to be below V6 and run
npm install [email protected]
or otherwise checkout the new version for new updates.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alireza Jahandoost |
Solution 2 |