visgl / visgl/react-google-maps
[Bug] Event listener on map initialized by defaultBounds causes warning in console
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 193
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 13
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- react, typescript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100