[Error] A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>

Hello Everyone!

Please help me! I am trying to do the PetLover project with React Router. I am stuck on step 5. It said: " Wrap your HomePage component in a Route component. The Route should have a path prop of /:type so that the home page will render the species specified by the value of the URL parameter."
That is what I have done!

<Router>
      <Navigation />
        <Route path='/:type'>
          <HomePage />
        </Route>
    </Router>

But then, it shows an error “A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .”

Therefore, I do what the error says.

<Router>
      <Navigation />
        <Routes>
          <Route path='/:type'>
            <HomePage />
          </Route>
        </Routes>
    </Router>

But then it appears a new error: “[HomePage] is not a component. All component children of must be a or <React.Fragment>”

And, Here is where I am stuck. please help!

Thank you!

Sorry guys! I make a research and I found that I installed the wrong version for react-router!
Thanks!

:grin:

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.