Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion about Switch on app.js and the react-router-dom dependency #6

Open
chavez-carlos opened this issue Nov 24, 2021 · 0 comments

Comments

@chavez-carlos
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant