react-leaflet icon indicating copy to clipboard operation
react-leaflet copied to clipboard

"Map container is already initialized." error happens when component is in Suspense

Open jisuo opened this issue 1 year ago • 3 comments

Bug report in v4

Before opening an issue, make sure to read the contributing guide and understand this is a bug tracker, not a support platform.

Please make sure to check the following boxes before submitting an issue.
Issues opened without using this template will be closed unless they have a good reason not to follow this template.

  • [x] All peer dependencies are installed: React, ReactDOM and Leaflet.
  • [x] Using the latest version of React and ReactDOM v18.
  • [x] Using the supported version of Leaflet (v1.8.0 minimum) and its corresponding CSS file is loaded.
  • [x] Using the latest v4 version of React-Leaflet.
  • [x] The issue has not already been reported.
  • [x] Make sure you have followed the quick start guide for Leaflet.
  • [x] Make sure you have fully read the documentation and that you understand the limitations.

Expected behavior

The error "Map container is already initialized." should not happen when Suspense happens.

Actual behavior

The error "Map container is already initialized." happens when Suspense happens.

Steps to reproduce

Code example to reproduce using react-query to trigger Suspense state. Click the Button to trigger fake api fetch to trigger Suspense state.

https://codesandbox.io/s/modest-noyce-qy21ix?file=/src/Map.tsx](https://codesandbox.io/s/modest-noyce-qy21ix?file=/src/Map.tsx:1017-1126)

jisuo avatar Mar 21 '23 09:03 jisuo