-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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(react-router): remove page transition flicker on outlet mounting #24667
Conversation
*/ | ||
this.pendingPageTransition = true; | ||
|
||
this.setState({ |
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.
This may be redundant. Open to feedback for those that are more familiar with how React handles internal state changes.
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.
@sean-perkins - are you tossing routeInfo
into state as a way to get another render so that pendingPageTransition
can be evaluated? Would it be clearer to put pendingPageTransition
into state (instead of an instance variable) and use it from state?
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 componentOnReady
helper may be of use here: https://github.com/ionic-team/ionic-framework/blob/main/core/src/utils/helpers.ts#L70
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.
I was trying to maintain as much previous code behavior, of passing the context of routeInfo
from the original function call, back when the function should be handled.
Although, I don't believe routeInfo
can change between the time React component is first constructed and the first render cycle. So I believe the setState
is just re-assigning the same value and can be removed. I did brief testing of removing that call and tests passed and behavior seemed appropriate.
The important piece is just catching when a page transition happens on a component that hasn't mounted (typically from routing directly to a view in a nested outlet) and re-handling that when the component is available.
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.
I don't believe componentOnReady
will be applicable here. The most common state of this happening, was when routerOutlet
(the element ref) was undefined
.
From testing, it does not appear to be needed in the componentDidUpdate
life cycle 👍
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
On initial load, when using nested router outlets with React, another outlet can briefly display before the enter view & outlet has mounted.
Issue Number: #24666
What is the new behavior?
computedMatch
) that is no longer available in v6.tabs
attribute when cloning the page elementDoes this introduce a breaking change?
Other information
Kapture.2022-01-26.at.19.45.15.mp4
Kapture.2022-01-26.at.20.01.10.mp4
Note: I am refreshing the browser in both examples.