I am using React Router with React Transition Group to animate between routes. I have a problem when I use a <Redirect /> component. The App works, but I get multiple warnings from React Router that reads:
Warning: You tried to redirect to the same route you're currently on: "/"
You can see it happen in this Code Sandbox. Make sure to open the sandbox console and then enter a bad path (like codesandbox.io/abc).
I tried following the example they give in their docs (https://reacttraining.com/react-router/web/example/animated-transitions), but that does not include a Redirect. Is there a better way to use Redirect and Transitions to avoid the warnings?
locationprop on theSwitchseems to fix it for me: codesandbox.io/s/w7j1kk8m17 - Chase DeAndalocationprop, the current route changes immediately. I slowed down the animation in my original sandbox to better illustrate. codesandbox.io/s/ly9l09m22q Watch the word that animates out when you click. - Steve Rlocationprop isn't updating immediately and is causing multiple redirects to fire off before it updates. - Chase DeAndalocationis updating properly. If I log it out in therender, I see render called twice and two logs with the expectedlocation.path, followed by 3 of the above warning. If I remove the TransitionGroup components, I still see those same two logs (and no warnings). Could you suggest a way to test your theory? - Steve R