Episode 22 of 32

Exact Match Routes

Use exact match to prevent multiple routes from rendering simultaneously.

Without exact, React Router matches routes partially.

The Problem

The path /create also matches / — so both routes render.

The Fix

<Route exact path="/">
  <Home />
</Route>
<Route path="/create">
  <Create />
</Route>

The exact prop ensures the route only matches when the path is an exact match.