• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

85
Views
how does this error means in react-router-dom?

when I import switch from react-router-dom error screen shot when I import switch from react-router enter image description here

I copied code from https://v5.reactrouter.com/web/guides/quick-start

4 months ago ·

Santiago Trujillo

3 answers
Answer question

0

Switch is exported from "react-router", not from "react-router-dom"

Convert this:

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

to:

import { Switch } from "react-router";
4 months ago · Santiago Trujillo Report

0

Hello because Switch is exported from react-router

import { Switch } from "react-router";
4 months ago · Santiago Trujillo Report

0

I have faced similiar problem with importing Switch from react-router-dom. In my case, I was using the latest (v6, i think) version of react-router-dom where the "Switch" is replaced by "Routes".

So either you check your react-router-dom's version and replace Switch to Routes and change the Route declaraton from <Route path="/" component={Dashboard} /> to <Route path="/" element={Dashboard} /> if it's v6, or you want to downgrade your react-router-dom version and keep using Switch.

Your call.

4 months ago · Santiago Trujillo Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.