Skip to content

[Bug] "No options were set" warning when Google Maps API is loaded externally #972

@celescript

Description

@celescript

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

  1. Load the Maps JS API via any external mechanism before APIProvider mounts (e.g. a legacy useGoogleMaps hook that injects a <script> tag)
  2. Render APIProvider with a valid apiKey
  3. Use useMapsLibrary in any child component
  4. 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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions