Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map Block: Fix Mapbox maps and markers in React's Strict Mode (#37918)
* Map Block: Handle React's Strict Mode for Mapbox Markers In Strict Mode, react will mount, unmount, then remount each compontent to make sure components handle unmounting correctly. When Mapbox Markers are unmounted, remove them from the map, and also lose the reference to them so that when we remount, we create a new Marker. * Map Block: Handle React's Strict Mode for Mapbox Maps In Strict Mode, react will mount, unmount, then remount each compontent to make sure components handle unmounting correctly. Whe Mapbox maps are mounted, we kick off an asynchronous callback to load the Mapbox library. Because that callback is asynchronous, it can be called after the component has been unmounted, which can lead to initializing the map twice (once after the mount/unmount and once after the remount). Ideally, we'd catch that case and not initialize a map after the component has been unmounted. Instead, when we initialize the map, check if there is already an initialized map and remove it. * changelog
- Loading branch information