Prevent WithAPIData promises from getting orphaned when refreshing

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
Mcat12
2019-01-18 18:36:32 -08:00
parent 4764723c36
commit f2fe9d5aa7
+5
View File
@@ -64,6 +64,11 @@ export class WithAPIData extends Component {
interval: this.props.repeatOptions.interval
};
// Clear in-flight or repeating requests so they are not orphaned
if (this.dataHandle) {
this.dataHandle.cancel();
}
this.dataHandle = makeCancelable(this.props.apiCall(), cancelOptions);
this.dataHandle.promise