Open Prinzhorn opened 2 years ago
Any suggestion to solve this? I don't want to rise a timer for each redirect action.
Can you check if the to-be-redirected URL exactly matches the current URL (including hash, query and everything)? I doubt anyone wants to have the exact same URL twice in the history stack.
How to detect this case?
<Route path="/bar" redirect="/foo"/>
<Route path="/foo" redirect="/bar"/>
I don't know if we need to go that far for a feature that's mainly meant to prevent users from shooting in their own foot.
An algorithm to solve this would be to build a graph of all redirects (/foo
-> /bar
and /bar
-> /foo
as two nodes with two edges) and check if it is free of cycles.
I think as a first step checking path === redirect
prop and then logging an error would be great.
<script context="module">
of <Route>
and each Route adds/updates/removes itself?path === redirect
would be one less bug
I was just typing
<Route path="/" redirect="/">
in REPL (for #81) and it froze my tab. I assume because of an endless redirect (my cursor was in theredirect
prop and I was about to type there).To reproduce open REPL and paste
<Route path="/" redirect="/" />
It should detect that edge case and not run into an endless loop. Mistakes happen and if
path
orredirect
are dynamic this would lock up an app.Maybe add a
console.error
for this case in dev mode