Description
When the Google Maps JS API is loaded externally (e.g. via a separate script loader) before APIProvider mounts, APIProvider's effect detects window.google.maps.importLibrary already exists and takes the early-exit path, correctly skipping its own script load. However, it returns without ever calling setOptions(), so setOptionsWasCalled_ remains false. Every subsequent call to the internal importLibrary wrapper then fires the dev warning.
So the suggestion "use a single loader / remove the external script tag" is a valid workaround, but the actual bug is that vis.gl warns about a situation it intentionally supports and handles correctly.
Steps to Reproduce
- Load the Maps JS API via any external mechanism before APIProvider mounts (e.g. a legacy useGoogleMaps hook that injects a <script> tag)
- Render APIProvider with a valid apiKey
- Use useMapsLibrary in any child component
- Observe the warning in the browser console (dev mode only)
Environment
- Library version: @vis.gl/react-google-maps@1.8.3
- Google maps version: weekly
- Browser and Version: Chrome Version 147.0.7727.116
- OS: macOS 15.7.4
Logs
[@googlemaps/js-api-loader] No options were set before calling importLibrary. Make sure to configure the loader using setOptions().
Description
When the Google Maps JS API is loaded externally (e.g. via a separate script loader) before APIProvider mounts, APIProvider's effect detects window.google.maps.importLibrary already exists and takes the early-exit path, correctly skipping its own script load. However, it returns without ever calling setOptions(), so setOptionsWasCalled_ remains false. Every subsequent call to the internal importLibrary wrapper then fires the dev warning.
So the suggestion "use a single loader / remove the external script tag" is a valid workaround, but the actual bug is that vis.gl warns about a situation it intentionally supports and handles correctly.
Steps to Reproduce
Environment
Logs