Redirecting with lifecycle solution
The answer can be found to the code above.
First inside the render function of the component, we inject the redirect to /home, but take care, this will be executed only when the shouldRedirect variable of component's state is set to true.
This is initialized as false, but then every time this component renders, we set a timeout function, and after 5 seconds we change a state's variable. We use the componentDidMount lifecycle method for achieving this.
The change of state will execute the render function with the new variables' values, and this will trigger the redirect component, which will lead the user to the /home page.