-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby): route lifecycle ordering #27261
fix(gatsby): route lifecycle ordering #27261
Conversation
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.
Looks good, thanks for the tests! This is amazing!
Hey ! This completely breaks plugins like https://transitionlink.tylerbarnes.ca/docs/anilink/ |
This might cause the following issue: #27351 |
@@ -222,6 +216,12 @@ class RouteUpdates extends React.Component { | |||
return false | |||
} | |||
|
|||
componentDidUpdate(prevProps) { | |||
if (this.props.location.pathname !== prevProps.location.pathname) { |
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.
Does this break when other than pathname
parts of location are changing? I.e. search
, as a result causing problems like #27261
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.
Good spot! but I do find it strange how this can cause problems like this because the comparison has not changed.
I removed getSnapshotBeforeUpdate
which returned a boolean based on the same condition this.props.location.pathname !== prevProps.location.pathname
.
That boolean was then passed into componentDidUpdate
as the third parameter which is what was being used as the condition just like what I am doing here but without the third param.
So I am not sure I understand why this wasn't an issue before. Regardless - I am happy to investigate this 👍
Fix for location effect triggering here: #27594 & Published in |
* fixing ordering issue by using shouldComponentUpdate * creating cypress command to check order of actions called * enabling second page to be able to log lifecycle actions * writing e2e test to ensure the issue has been fixed and will not return * removing un-needed findIndex
Description
Rendering is occurring before
onPreRouteUpdate
when it should be after.Please see Issue #26608 for a full description.
Related Issues
Fixes #26608