From b5b081c2f2f873e56dd1f67b5f30bba880a45e59 Mon Sep 17 00:00:00 2001 From: Pierre Poupin Date: Mon, 13 Apr 2020 02:49:41 +0200 Subject: [PATCH] add ref existence check to fix 'failed to execute unobserve' error Solves #84 --- src/ArcherContainer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ArcherContainer.js b/src/ArcherContainer.js index ffa8c28..2174249 100644 --- a/src/ArcherContainer.js +++ b/src/ArcherContainer.js @@ -198,7 +198,9 @@ export class ArcherContainer extends React.Component { unregisterChild = (id: string): void => { this.setState((currentState: State) => { - currentState.observer.unobserve(currentState.refs[id]); + if (currentState.refs[id]) { + currentState.observer.unobserve(currentState.refs[id]); + } const newRefs = { ...currentState.refs }; delete newRefs[id]; return { refs: newRefs };