We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When used inside a flex container that prompts it to change size, the react leaflet map container does not correctly update it's own size.
May be related to the following issue, where solutions could be found PaulLeCam/react-leaflet#340
The text was updated successfully, but these errors were encountered:
I believe I am also experiencing this. As a stop gap measure, I'm updating the key when the size changes.
Sorry, something went wrong.
This is now working for me:
import { useEffect, useRef } from "react"; import { MapContainer } from "react-leaflet"; const MAP_CONTAINER_ID = "map-container"; export const ResizableMapContainer = ({ boundsFromContext }) => { const mapRef = useRef(null); const resizeObserverRef = useRef(null); useEffect(() => { return () => { resizeObserverRef.current?.disconnect(); }; }, []); const handleWhenReady = () => { resizeObserverRef.current = new ResizeObserver(() => mapRef.current?.invalidateSize() ); const mapContainer = document.getElementById(MAP_CONTAINER_ID); if (mapContainer) { resizeObserverRef.current.observe(mapContainer); } }; return ( <MapContainer ref={mapRef} id={MAP_CONTAINER_ID} whenReady={handleWhenReady} > {/* stuff */} </MapContainer> ); };
No branches or pull requests
When used inside a flex container that prompts it to change size, the react leaflet map container does not correctly update it's own size.
May be related to the following issue, where solutions could be found PaulLeCam/react-leaflet#340
The text was updated successfully, but these errors were encountered: