InterviewHubPRO
Section Overview
Q86

Question 86 of 445

Part 2: React Router & Navigation (78 - 88)

19%
React & Modern Frontend (445 Qs)•Part 2: React Router & Navigation (78 - 88)

How to implement _default_ or _NotFound_ page?

A <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

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