September 2018
Beginner
156 pages
3h 28m
English
From the previous example, let's redirect the user from the / path to the /home path using the <Redirect> component:
<Route path="/" render={() => <Redirect to="/home" />} exact/>
When you try accessing the URL http://localhost:3001/, you will notice that the redirection does not take place and the browser's URL is not updated. The preceding redirect would have sufficed in the client-side environment. However, in the server-side environment, the server is responsible for handling the redirect. In this case, the context object mentioned in the <StaticRouter> component is populated with necessary details:
{ "action": "REPLACE", "location": { "pathname": "/home", "search": "", "hash": ...Read now
Unlock full access