tomchentw / react-google-maps

React.js Google Maps integration component
https://tomchentw.github.io/react-google-maps/
MIT License
4.62k stars 939 forks source link

fix app crash because google is undefined in a PWA if the user is offline and cache is disabled. #956

Open xMokAx opened 5 years ago

xMokAx commented 5 years ago

When i open my app in offline mode if [https://maps.googleapis.com/maps/api/js]() is not available in browser cache like disk cache the app craches because google is not defined. You can see the error here [https://xmokax.github.io/map-app/]() by following these steps:

  1. open the app and wait for service worker to install and finish precaching assets.
  2. reload the page and then go to the network tab in the developer tools and choose offline then reload the app. The app will work because google maps script will be served from disk cache.
  3. go to network tab in developer tools and choose both offline and disable cache too then reload the page the app will crash because google is not defined.

This PR to fixes this problem.

JustFly1984 commented 5 years ago

Hello @xMokAx this repo is unmaintained, and pull requests does not merged since more than a year. Please consider to use a successor library react-google-maps-api https://github.com/JustFly1984/react-google-maps-api