Skip to content Skip to sidebar Skip to footer

React-router V4 Showing Multiple Routes At Once

I am having an issue where my routing using react-router-dom is showing all routes at once. So when I render my App component and the start that contains the Routing, I am seeing

Solution 1:

From the React Training :

Routes without a path always match.

So in your case both will always match because u are using pattern.


Solution 2:

You need to add Switch tag . It will switch between your components.

const App = () => { 
return ( <Router> 
          <Switch>  <Route exact path='/' component={Login}/> 
          <Route exact path='/home' component={Home}/> 
          </Switch> 
         </Router> ); };

Post a Comment for "React-router V4 Showing Multiple Routes At Once"