-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Redirect: Support props changes on Redirect to handle edge cases * Redirect: Fixed tests after moving to Jest * Use `createLocation` to parse `to` to properly handle edge cases
- Loading branch information
1 parent
fe16632
commit 2807350
Showing
2 changed files
with
156 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2807350
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that this change can fail if from/referrer is used, it then gets stuck in an infinite recursion. Adding this test would be good.
2807350
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whitelizard Can you do a PR?
2807350
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something other than these?
or
Either of those use cases should be on the user to properly handle.
2807350
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Redirect to={{ pathname: '/home', state: { from: currentLocation }, }} />
Failes hard (infinite recursion due to the equal check) if you somehow are on /home. But I guess you mean that the user should prevent this, and I might agree.
We just got this crazy error after the update and traced it to this commit. (Our code could get into a situation of redirecting twice).
2807350
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
locationsAreEqual
call should catch when you are attempting to redirect to the same location as the previous redirect. Since that isn't happening for you, there might be a bug, but I would have to see the code that is triggering this. My current guess is that the<Redirect>
is mounting on each render for some reason, which is why the update check is not preventing the recursion.