hotfix: remove didMount from daemon hoc

This commit is contained in:
George Lima 2018-12-11 19:28:05 -03:00
parent 6393a4656b
commit 9100665042
1 changed files with 10 additions and 11 deletions

View File

@ -21,14 +21,7 @@ export const withDaemonStatusCheck = <PassedProps: {}>(
componentDidMount() {
this.runTest();
this.timer = setInterval(() => this.runTest(), 3000);
}
componentDidUpdate(prevProps: Props, prevState: State) {
if (!prevState.isRunning && this.state.isRunning && this.timer) {
clearInterval(this.timer);
this.timer = null;
}
this.timer = setInterval(this.runTest, 2000);
}
componentWillUnmount() {
@ -38,11 +31,17 @@ export const withDaemonStatusCheck = <PassedProps: {}>(
}
}
runTest() {
runTest = () => {
rpc.getinfo().then((response) => {
if (response) this.setState(() => ({ isRunning: true }));
if (response) {
this.setState(() => ({ isRunning: true }));
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
}
});
}
};
render() {
if (this.state.isRunning) {