Merge pull request #1804 from lbryio/subscriptions-loader-fix

Fix loading indicator on Page component
This commit is contained in:
Sean Yesmunt 2018-07-23 18:46:42 -04:00 committed by GitHub
commit ee5922a8ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,10 +39,16 @@ class Page extends React.PureComponent<Props, State> {
componentDidUpdate(prevProps: Props) {
const { loading } = this.props;
const { showLoader } = this.state;
if (!this.loaderTimeout && !prevProps.loading && loading) {
this.beginLoadingTimeout();
} else if (!loading && this.loaderTimeout) {
clearTimeout(this.loaderTimeout);
if (showLoader) {
this.removeLoader();
}
}
}
@ -58,6 +64,10 @@ class Page extends React.PureComponent<Props, State> {
}, LOADER_TIMEOUT);
}
removeLoader() {
this.setState({ showLoader: false });
}
loaderTimeout: ?TimeoutID;
render() {