diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cb09f75..8d649cba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v3.2.5 (2022-01-15) + +Fix supporting mutable `whenCreated` with unmounting `MapContainer`. + ## v3.2.4 (2022-01-09) Fix removing the map handlers when `MapContainer` is unmounted. diff --git a/packages/react-leaflet/package.json b/packages/react-leaflet/package.json index 9543b31e..5967dbc2 100644 --- a/packages/react-leaflet/package.json +++ b/packages/react-leaflet/package.json @@ -1,6 +1,6 @@ { "name": "react-leaflet", - "version": "3.2.4", + "version": "3.2.5", "description": "React components for Leaflet maps", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/packages/react-leaflet/src/MapContainer.tsx b/packages/react-leaflet/src/MapContainer.tsx index c943ef31..739576f6 100644 --- a/packages/react-leaflet/src/MapContainer.tsx +++ b/packages/react-leaflet/src/MapContainer.tsx @@ -71,11 +71,13 @@ export function MapContainer< createdRef.current = true whenCreated(map) } + }, [map, whenCreated]) + useEffect(() => { return () => { map?.remove() } - }, [map, whenCreated]) + }, [map]) const [props] = useState({ className, id, style }) const context = useMemo(