Closed simonnilsson closed 2 years ago
@simonnilsson can you post a codesandbox with this issue? I tried upgrading the example to react-leaflet 3.2.4 but it still works. Here is an example of mounting and unmounting the map every 3 seconds: https://codesandbox.io/s/basic-usage-with-react-leaflet-v3-forked-bstxg
Hi @aviklai, the root problem seems to be in the lifecycle of react-leaflet and not really related to this module. I'm guessing the error about google is just a red herring.
I was able to reproduce it here, you can see the above error briefly before it goes over to showing "Map container is being reused by another instance" which is probably the real problem. https://codesandbox.io/s/basic-usage-with-react-leaflet-v3-forked-37q7d
Notice the use of whenCreated callback whenCreated={(mapRef) => setMap(mapRef)}
that seems to cause the problem.
There is an issue open about it here: https://github.com/PaulLeCam/react-leaflet/issues/943
Breaks on updating from v3.2.3 to v3.2.4.
The change made was:
Fix removing the map handlers when MapContainer is unmounted.
https://github.com/PaulLeCam/react-leaflet/commit/9f88d1112f7baa287256a25b1c72da0904e83711
Leads to this error:
Likely something that needs to be fixed in Leaflet.GridLayer.GoogleMutant.