Skip to content

Commit

Permalink
Merge pull request #88 from pierpo/fix/unobserve-error
Browse files Browse the repository at this point in the history
Add ref existence check to fix 'failed to execute unobserve' error
  • Loading branch information
pierpo authored Apr 19, 2020
2 parents 9b53933 + b5b081c commit 2b1d963
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ArcherContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ export class ArcherContainer extends React.Component<Props, State> {

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 };
Expand Down

0 comments on commit 2b1d963

Please sign in to comment.