From f2fe9d5aa77bbb3520aa90de61397eccdc468cbb Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 18 Jan 2019 18:36:32 -0800 Subject: [PATCH] Prevent WithAPIData promises from getting orphaned when refreshing Signed-off-by: Mcat12 --- src/components/common/WithAPIData.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/common/WithAPIData.js b/src/components/common/WithAPIData.js index 575d393..6df0cfd 100644 --- a/src/components/common/WithAPIData.js +++ b/src/components/common/WithAPIData.js @@ -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