September 2018
Beginner
156 pages
3h 28m
English
The <Redirect> component is included in the react-router-dom package. It helps in redirecting the user from the component where it's included to the route specified in the 'to' prop:
import { Redirect } from 'react-router-dom';export class HomeComponent extends Component { render() { return ( <Redirect to='/dashboard' /> ) }}In the preceding scenario, when HomeComponent is rendered (based on a <Route> match), the user is redirected to the '/dashboard' route. For example, when the user accesses the home page (at path '/'), the <Route> with the path '/' renders the previous component and then the user is immediately redirected to the <Route> with its path value as '/dashboard'. This is similar to how a <Link> or ...
Read now
Unlock full access