The routes defined using the <Route> component can be accessed through the browser's URL, by navigating to the route using <Link> or <NavLink>, or by redirecting the user with the <Redirect> component. However, in most applications, some of the routes should be accessible only to authorized or logged-in users. For example, say the /user path displays the logged-in user's data; this path should be protected and only the logged-in user should be allowed to access the route. In these cases, the <Redirect> component comes in handy for redirecting the user to the login page (at the path /login) when you try to access the path /user.
To demonstrate this, let's create a component called UserComponent, which will be rendered when you try to access the path /user:
export class UserComponent extends Component...