From 604be1e073e478db292772b09812354ef7f5ff3f Mon Sep 17 00:00:00 2001 From: kal Date: Sat, 7 Apr 2018 19:15:32 -0400 Subject: [PATCH] added if statement in onRemove() function Added an if statement in onRemove() function that checks if "this.div" is defined before calling ReactDOM.unmountComponentAtNode(this.div). This is done to avoid throwing an "unmountComponentAtNode(...): Target container is not a DOM element" error. I ran into this error while using google-map-react with React Router and switching between tabs rapidly to stress test my application. --- src/google_map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google_map.js b/src/google_map.js index 9416a584..f44d2702 100644 --- a/src/google_map.js +++ b/src/google_map.js @@ -610,7 +610,7 @@ export default class GoogleMap extends Component { }, onRemove() { - ReactDOM.unmountComponentAtNode(this.div); + if(this.div) ReactDOM.unmountComponentAtNode(this.div); }, draw() {