score:2

Accepted answer

use the exact prop in your home route.

            <route exact path="/" component={home} />

score:1

i would add a <route> component without providing path that should redirect to 404 one.

try the following:

<switch>
    <route exact path="/badges" component={badges} />
    <route exact path="/badges/new" component={newbadge} />
    <route path="/404" component={notfound} />
    <route path="/" component={home} />
    <route component={notfound} />
</switch>

i hope this helps!

score:1

i think you can do this:

<switch>
    <route exact path="/badges" component={badges} />
    <route exact path="/badges/new" component={newbadge} />
    <route exact path="/" component={home} />
    <route component={notfound} />
</switch>

Related Query

More Query from same tag