September 2018
Beginner
156 pages
3h 28m
English
The <Switch> component's children can include a list of <Route> and <Redirect> components as well. The <Redirect> component, when included as the last entry in <Switch>, will redirect the user to the given path if none of the <Route> mentioned above the <Redirect> component match the browser's URL:
<Switch> <Route path="/login" component={LoginComponent} /> <Route path="/user" render={({ match }) => <div> Route with path {match.url}</div> } /> <Redirect to="/home" /></Switch>The <Redirect> component mentioned previously redirects the user to the <Route> with path /home. This is similar to displaying a 404: Page Not Found page; instead of displaying the component in line, ...
Read now
Unlock full access