Skip to content

Commit

Permalink
fix(src/withGoogleMap): crash when google is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Lindehoff committed Jul 13, 2018
1 parent ca5c5c6 commit b703210
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/withGoogleMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ export function withGoogleMap(BaseComponent) {
}

handleComponentMount(node) {
if (this.state.map || node === null) {
return
}
warning(
`undefined` !== typeof google,
`Make sure you've put a <script> tag in your <head> element to load Google Maps JavaScript API v3.
If you're looking for built-in support to load it for you, use the "async/ScriptjsLoader" instead.
See https://github.com/tomchentw/react-google-maps/pull/168`
)

if (this.state.map || node === null || google == null) {
return
}
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map
const map = new google.maps.Map(node)
this.setState({ map })
Expand Down

0 comments on commit b703210

Please sign in to comment.