remove the spinner if necessary after clearing the timeout
This commit is contained in:
parent
8ee815a84b
commit
bf8ada27d7
1 changed files with 10 additions and 0 deletions
|
@ -39,10 +39,16 @@ class Page extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
componentDidUpdate(prevProps: Props) {
|
componentDidUpdate(prevProps: Props) {
|
||||||
const { loading } = this.props;
|
const { loading } = this.props;
|
||||||
|
const { showLoader } = this.state;
|
||||||
|
|
||||||
if (!this.loaderTimeout && !prevProps.loading && loading) {
|
if (!this.loaderTimeout && !prevProps.loading && loading) {
|
||||||
this.beginLoadingTimeout();
|
this.beginLoadingTimeout();
|
||||||
} else if (!loading && this.loaderTimeout) {
|
} else if (!loading && this.loaderTimeout) {
|
||||||
clearTimeout(this.loaderTimeout);
|
clearTimeout(this.loaderTimeout);
|
||||||
|
|
||||||
|
if (showLoader) {
|
||||||
|
this.removeLoader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +64,10 @@ class Page extends React.PureComponent<Props, State> {
|
||||||
}, LOADER_TIMEOUT);
|
}, LOADER_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeLoader() {
|
||||||
|
this.setState({ showLoader: false });
|
||||||
|
}
|
||||||
|
|
||||||
loaderTimeout: ?TimeoutID;
|
loaderTimeout: ?TimeoutID;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue