From f06fea699f868e2b12d94c171138145c9e616cb9 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 1 Mar 2026 20:27:50 +0100 Subject: [PATCH] Fix WorldMap crash when path is undefined during early render react-simple-maps types declare path as always non-null, but it is undefined during the initial render before the MapProvider context has fully initialised. Guard with an early return after all hooks have been called, casting through unknown to reflect the true runtime type without triggering the @typescript-eslint/no-unnecessary-condition rule. --- frontend/src/components/WorldMap.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/components/WorldMap.tsx b/frontend/src/components/WorldMap.tsx index 1b3b9f7..5cd4c59 100644 --- a/frontend/src/components/WorldMap.tsx +++ b/frontend/src/components/WorldMap.tsx @@ -83,6 +83,12 @@ function GeoLayer({ [selectedCountry, onSelectCountry], ); + // react-simple-maps types declare `path` as always defined, but it is + // undefined during early renders before the MapProvider context initialises. + // Cast through unknown to reflect the true runtime type and guard safely. + const safePath = path as unknown as typeof path | null; + if (safePath == null) return <>; + return ( <> {(geographies as { rsmKey: string; id: string | number }[]).map(