Skip to content

Commit eb415a7

Browse files
author
Tobias Lindehoff
committed
fix(src/withGoogleMap): crash when google is not defined
1 parent ca5c5c6 commit eb415a7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/withGoogleMap.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ export function withGoogleMap(BaseComponent) {
4646
}
4747

4848
handleComponentMount(node) {
49-
if (this.state.map || node === null) {
50-
return
51-
}
5249
warning(
5350
`undefined` !== typeof google,
5451
`Make sure you've put a <script> tag in your <head> element to load Google Maps JavaScript API v3.
5552
If you're looking for built-in support to load it for you, use the "async/ScriptjsLoader" instead.
5653
See https://github.com/tomchentw/react-google-maps/pull/168`
5754
)
55+
56+
if (this.state.map || node === null || "undefined" === typeof google) {
57+
return
58+
}
5859
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map
5960
const map = new google.maps.Map(node)
6061
this.setState({ map })

0 commit comments

Comments
 (0)