+1 vote
in ReactJS by

Why you get "Router may have only one child element" warning?

1 Answer

0 votes
by

You have to wrap your Route's in a <Switch> block because <Switch> is unique in that it renders a route exclusively.

At first you need to add Switch to your imports:

import { Switch, Router, Route } from 'react-router'

Then define the routes within <Switch> block:

<Router>
  <Switch>
    <Route {/* ... */} />
    <Route {/* ... */} />
  </Switch>
</Router>

Related questions

0 votes
asked Dec 2, 2021 in Cloud Computing by DavidAnderson
0 votes
asked May 21, 2022 in AngularJS Packaging and Testing by sharadyadav1986
...