While using react-router for quite some time, I wonder can we do programmatically throw 404 page in react-router v5 ?
CodePudding user response:
You can use Redirect from react router. Rendering <Redirect>
will navigate to a new location. The new location will override the current location in the history stack. For example:
<Route exact path="/">
{loggedIn ? <Redirect to="/page_not_found" /> : <PublicHomePage />}
</Route>
CodePudding user response:
You can get to the 404 page in the following ways:
<Route path = "/*" element={} />