refactor(core): lower timeout before rendering progress bar to 200ms (#7142)

This commit is contained in:
Joshua Chen 2022-04-09 20:19:17 +08:00 committed by GitHub
parent 0dc7f0ff14
commit b50def3ac0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -38,7 +38,7 @@ export default function App(): JSX.Element {
<BaseUrlIssueBanner /> <BaseUrlIssueBanner />
<PendingNavigation <PendingNavigation
location={normalizeLocation(location)} location={normalizeLocation(location)}
delay={1000}> delay={200}>
{routeElement} {routeElement}
</PendingNavigation> </PendingNavigation>
</Root> </Root>

View file

@ -56,7 +56,7 @@ class PendingNavigation extends React.Component<Props, State> {
// Save the location first. // Save the location first.
this.previousLocation = this.props.location; this.previousLocation = this.props.location;
this.setState({nextRouteHasLoaded: false}); this.setState({nextRouteHasLoaded: false});
this.startProgressBar(this.props.delay); this.startProgressBar();
// Load data while the old screen remains. // Load data while the old screen remains.
preload(nextLocation.pathname) preload(nextLocation.pathname)
@ -86,14 +86,14 @@ class PendingNavigation extends React.Component<Props, State> {
} }
} }
private startProgressBar(delay: number) { private startProgressBar() {
this.clearProgressBarTimeout(); this.clearProgressBarTimeout();
this.progressBarTimeout = window.setTimeout(() => { this.progressBarTimeout = window.setTimeout(() => {
clientLifecyclesDispatcher.onRouteUpdateDelayed({ clientLifecyclesDispatcher.onRouteUpdateDelayed({
location: this.props.location, location: this.props.location,
}); });
nprogress.start(); nprogress.start();
}, delay); }, this.props.delay);
} }
private stopProgressBar() { private stopProgressBar() {