Reset the state after unmount
The previous solution works well for now, but generates a specific problem.
Now that the shouldRedirect is set to true, will stay like that forever. That means if we navigate to this component again, we are going to redirect immediately and not after 5 seconds, since the value is true and this fact will trigger the Redirect component.
What you should do, is reset the shouldRedirect state's value again to back to false, immediately after the component unmounts.
Hint: Maybe you will find componentWillUnmount lifecycle method extremely useful here.