Skip to content

Commit

Permalink
fix app crash because google is undefined in a PWA if the user is off…
Browse files Browse the repository at this point in the history
…line and cache is disabled.
  • Loading branch information
xMokAx committed Jan 17, 2019
1 parent ca5c5c6 commit 2d17e64
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/withGoogleMap.jsx
Expand Up @@ -49,12 +49,15 @@ export function withGoogleMap(BaseComponent) {
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 (`undefined` === typeof google) {
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`
)
)
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 2d17e64

Please sign in to comment.