[Bug] Event listener on map initialized by defaultBounds causes warning in console

Open
#549 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
api, frontend

Research direction

Start by reproducing the provided Map example, then inspect use-map-events.ts around createMapEvent and use-map-instance.ts around the fitBounds call shown in the stack trace. Done means initializing defaultBounds with onCenterChanged no longer produces the console warning; verify the reproduction after the change.

Written by the indexing model from the issue text.

Description

bug
Description

Warning in console when initializing a map with defaultBounds and adding an event listener:

main.js:169 [createEvent] at least one of the values from the map returned undefined. This is not expected to happen. Please report an issue at https://github.com/visgl/react-google-maps/issues/new

Steps to Reproduce
import React from 'react';
import {
  APIProvider,
  Map,
} from '@vis.gl/react-google-maps';

import './App.css';

const API_KEY = '';
const MAP_ID = '';

export default function MyApp() {
  return (
    <APIProvider apiKey={API_KEY}>
      <Map
        id="map"
        mapId={MAP_ID}
        defaultBounds={{north: 45, south: 0, east: 0, west: 45}}
        onCenterChanged={() => {console.log('center changed')}}
      />
    </APIProvider>
  );
}
Environment
  • Library version: 1.2.0
  • Google maps version: weekly
  • Browser and Version: Chrome 129.0.6668.70
  • OS: Mint 22
Logs
main.js:169 [createEvent] at least one of the values from the map returned undefined. This is not expected to happen. Please report an issue at https://github.com/visgl/react-google-maps/issues/new
createMapEvent	@	use-map-events.ts:104
(anonymous)	@	use-map-events.ts:66
_.nk	@	main.js:169
tk	@	main.js:170
_.rk.set	@	main.js:294
(anonymous)	@	main.js:177
d	@	map.js:23
iC	@	map.js:24
(anonymous)	@	main.js:414
Promise.then		
fn.fitBounds	@	main.js:414
(anonymous)	@	use-map-instance.ts:157
commitHookEffectListMount	@	react-dom.development.js:23189
commitPassiveMountOnFiber	@	react-dom.development.js:24965
commitPassiveMountEffects_complete	@	react-dom.development.js:24930
commitPassiveMountEffects_begin	@	react-dom.development.js:24917
commitPassiveMountEffects	@	react-dom.development.js:24905
flushPassiveEffectsImpl	@	react-dom.development.js:27078
flushPassiveEffects	@	react-dom.development.js:27023
(anonymous)	@	react-dom.development.js:26808
workLoop	@	scheduler.development.js:266
flushWork	@	scheduler.development.js:239
performWorkUntilDeadline	@	scheduler.development.js:533
Show less
Dominant language
TypeScript
Stars
2k
Forks
195
Avg merge
6h 26m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from visgl/react-google-maps

All issues in visgl/react-google-maps

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.