if path ndont match redirect to 404 react code example
Example: react router catch all 404
<Switch>
<Route path="/" exact component={Home}/>
<Route path="/about" component={About}/>
<Route component={Page404} />
</Switch>
<Switch>
<Route path="/" exact component={Home}/>
<Route path="/about" component={About}/>
<Route component={Page404} />
</Switch>