Skip to content

Commit

Permalink
fix: map controls crashing when invalid key is provided (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
MauricioRobayo authored Apr 1, 2024
1 parent 5386035 commit 5052dfb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/map-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const MapControl = ({children, position}: MapControlProps) => {
controls.push(controlContainer);

return () => {
const index = controls.getArray().indexOf(controlContainer);
const controlsArray = controls.getArray();
// controlsArray could be undefined if the map is in an undefined state (e.g. invalid API-key, see #276
if (!controlsArray) return;

const index = controlsArray.indexOf(controlContainer);
controls.removeAt(index);
};
}, [controlContainer, map, position]);
Expand Down

0 comments on commit 5052dfb

Please sign in to comment.