M
M
Marat Shakirov2022-01-19 21:17:07
JavaScript
Marat Shakirov, 2022-01-19 21:17:07

Why is there no Switch export in 'React-router-dom' folder?

I installed the react routing package, when importing it in a component, it says that Switch is not exported, and indeed, there is no such export in the file in the 'React-router-dom' folder. Tried reinstalling - to no avail. And it's not in the 'react-router' folder either, nowhere...

Compiled with problems:X

WARNING in ./src/components/App.js 15:49-55

export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' (possible exports: BrowserRouter, HashRouter , Link, MemoryRouter, NavLink, Navigate, Outlet, Route, Router, Routes, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createRoutesFromChildren, createSearchParams, generatePath, matchPath, matchRoutes, renderMatches, resolvePath, unstable_HistoryRouter, useHref, useInRouterContext, useLinkClickHandler, useLocation, useNavigate , useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dima Pautov, 2022-01-19
@bootd

In the new, 6th version, something has changed! replace with Read the documentation. PS In Google it was possible to score like that
import { Switch, Route } from "react-router-dom";
import { Routes ,Route } from 'react-router-dom';

A
Alexander, 2022-01-19
@Seasle

Read the v5 to v6 migration guide . Or you can study the library documentation right away.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question