0 votes
in ReactJS by

How to implement default or NotFound page?

1 Answer

0 votes
by

<Switch> renders the first child <Route> that matches. A <Route> with no path always matches. So you just need to simply drop path attribute as below

<Switch>
  <Route exact path="/" component={Home}/>
  <Route path="/user" component={User}/>
  <Route component={NotFound} />
</Switch>

Related questions

+1 vote
asked Mar 2, 2020 in ReactJS by RShastri
0 votes
asked Apr 15, 2022 in ReactJS by Robindeniel
...