-
Notifications
You must be signed in to change notification settings - Fork 156
Open
Description
In the video, you utilized:
<Switch>
<Route path='/' exact component={Home} />
<Route path='/about' component={About} />
<Route path='/services' component={Services} />
<Route path='/contact-us' component={Contact} />
<Route path='/sign-up' component={SignUp} />
</Switch>
But I got some errors when compiling it: Attempted import error: 'Switch' is not exported from 'react-router-dom'
After investigating a little bit, I found that since v6 of react-router-dom, Switch is replaced by Routes, making this change on my project solved the issue:
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
...
<Routes>
<Route path='/' element={<Home/>} />
<Route path='/about' element={<About/>} />
</Routes>
I think it would be nice if you pinned a comment on the video or to update it.
Thanks for the tutorial.
edsmon, tuannkhoi, mitchglass97, david4tech, ParidV and 6 more
Metadata
Metadata
Assignees
Labels
No labels