Skip to content
New issue

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

Missing map shapes in summary step #791

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/components/Map/LeafletMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,27 @@
onGeoJsonGeometrySet?.(newFeatureLayer.toGeoJSON().geometry);
};

useEffect(() => {
// Remove all shapes from the map.
// Only `geoJsonGeometry` should be shown on the map.
featureGroupRef.current?.clearLayers();
if (!geoJsonGeometry) {
return;
}
// Add the current `geoJsonGeometry` as shape
const layer = Leaflet.GeoJSON.geometryToLayer(geoJsonGeometry);
featureGroupRef.current?.addLayer(layer);
}, [geoJsonGeometry]);
useEffect(
() => {
if (!featureGroupRef.current) {
// If there is no feature group, nothing should be done..
return;
}

// Remove all shapes from the map.
// Only `geoJsonGeometry` should be shown on the map.
featureGroupRef.current.clearLayers();
if (!geoJsonGeometry) {
return;

Check warning on line 106 in src/components/Map/LeafletMap.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/Map/LeafletMap.jsx#L106

Added line #L106 was not covered by tests
}
// Add the current `geoJsonGeometry` as shape
const layer = Leaflet.GeoJSON.geometryToLayer(geoJsonGeometry);
featureGroupRef.current.addLayer(layer);
},
// `featureGroupRef.current` is needed as dependency to make sure that
// the featureGroupRef can be used.
[geoJsonGeometry, featureGroupRef.current]

Check warning on line 114 in src/components/Map/LeafletMap.jsx

View workflow job for this annotation

GitHub Actions / Create storybook build

React Hook useEffect has an unnecessary dependency: 'featureGroupRef.current'. Either exclude it or remove the dependency array. Mutable values like 'featureGroupRef.current' aren't valid dependencies because mutating them doesn't re-render the component

Check warning on line 114 in src/components/Map/LeafletMap.jsx

View workflow job for this annotation

GitHub Actions / Create 'production' build

React Hook useEffect has an unnecessary dependency: 'featureGroupRef.current'. Either exclude it or remove the dependency array. Mutable values like 'featureGroupRef.current' aren't valid dependencies because mutating them doesn't re-render the component

Check warning on line 114 in src/components/Map/LeafletMap.jsx

View workflow job for this annotation

GitHub Actions / Create 'production' build

React Hook useEffect has an unnecessary dependency: 'featureGroupRef.current'. Either exclude it or remove the dependency array. Mutable values like 'featureGroupRef.current' aren't valid dependencies because mutating them doesn't re-render the component

Check warning on line 114 in src/components/Map/LeafletMap.jsx

View workflow job for this annotation

GitHub Actions / Create 'production' build

React Hook useEffect has an unnecessary dependency: 'featureGroupRef.current'. Either exclude it or remove the dependency array. Mutable values like 'featureGroupRef.current' aren't valid dependencies because mutating them doesn't re-render the component

Check warning on line 114 in src/components/Map/LeafletMap.jsx

View workflow job for this annotation

GitHub Actions / Lint code (ESLint)

React Hook useEffect has an unnecessary dependency: 'featureGroupRef.current'. Either exclude it or remove the dependency array. Mutable values like 'featureGroupRef.current' aren't valid dependencies because mutating them doesn't re-render the component
);

return (
<>
Expand Down
Loading