From 147997c5f7bdf6f7d5a475c17d6437f894515157 Mon Sep 17 00:00:00 2001 From: kal Date: Tue, 17 Apr 2018 13:20:09 -0400 Subject: [PATCH] added if statement in onRemove() function (#555) 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 9416a58..f44d270 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() {