You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I create a guard function that redirects to the same matched route, but with different params, the guard gets stuck in an infinite redirect loop and gives up eventually with an unrelated error.
Steps to reproduce
To the intermediate sample in src/router/index.tsx I added this GuardFunction:
constinvalidName=(to,from,next)=>{const{ name }=to.match.params;if(name==='test'){next.redirect('/charmander');}};
Description
If I create a guard function that redirects to the same matched route, but with different params, the guard gets stuck in an infinite redirect loop and gives up eventually with an unrelated error.
Steps to reproduce
To the intermediate sample in
src/router/index.tsx
I added thisGuardFunction
:and modified the
GuardedRoute
:Expected result
When given the route
localhost:3001/test
, I will get redirected tolocalhost:3001/charmander
.Actual result
When we get to the point of resolving the result to render
react-router-dom
components,matchPath
returnstrue
and the cycle continues.react-router-guards/package/src/Guard.tsx
Line 176 in a57d6a1
I'm guessing this was done to avoid infinite redirect loops, but here it's causing one.
Environment
The text was updated successfully, but these errors were encountered: