Skip to content

Commit

Permalink
map: fix state issue on initial render
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Nov 13, 2023
1 parent 01d9bca commit 022d6d2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion atciss-frontend/src/components/map/SectorPolygon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ export const SectorPolygon = ({
const [center, setCenter] = useState<LatLng | null>(null)

useEffect(() => {
if (polygon.current) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore (fixes "layer not on map", no public API)
if (polygon.current && polygon.current._map) {
setCenter(polygon.current.getCenter())
}

polygon.current?.on("add", () => {
polygon.current && setCenter(polygon.current.getCenter())
})
}, [polygon.current])

return (
Expand Down

0 comments on commit 022d6d2

Please sign in to comment.