Fix:UI console warning
@@ -59,6 +59,8 @@ export class WithLoader extends React.PureComponent<
minWait: 500,
};
+ public isCompMounted = false;
+
protected waitTimeout?: number;
constructor(props: IWithLoaderProps) {
@@ -75,11 +77,16 @@ export class WithLoader extends React.PureComponent<
}
public componentDidUpdate(prevProps: IWithLoaderProps) {
+ this.isCompMounted = true;
if (!this.props.loading && !this.waitTimeout) {
this.setTimeout();
}
}
+ public componentWillUnmount() {
+ this.isCompMounted = false;
+ }
+
public render() {
if (this.props.error) {
return this.props.errorChildren;
@@ -93,9 +100,11 @@ export class WithLoader extends React.PureComponent<
protected setTimeout() {
this.clearTimeout();
this.waitTimeout = window.setTimeout(() => {
+ if (this.isCompMounted) {
this.setState({
loaded: true,
});
+ }
}, this.props.minWait!);
}
