Skip to content

Commit

Permalink
front: fix undefined markerInfo.op in ItineraryMarkers
Browse files Browse the repository at this point in the history
When launching a pathfinding this error pops up in the console:

    Uncaught (in promise) TypeError: markerInfo.op is undefined
        trackId ItineraryMarkers.tsx:132
        fetchTrackSections ItineraryMarkers.tsx:132
        ItineraryMarkers ItineraryMarkers.tsx:136

Before SuggestedOP are fetched, markerInfo.op is undefined.

Guard against undefined values to avoid the error.

Signed-off-by: Simon Ser <[email protected]>
  • Loading branch information
emersion committed Feb 11, 2025
1 parent 9342d4c commit c46f4a5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ const ItineraryMarkers = ({

useEffect(() => {
const fetchTrackSections = async () => {
const trackId = markersInformation.map((markerInfo) => markerInfo.op!.track);
setTrackSections(await getTrackSectionsByIds(trackId));
const trackIds = markersInformation
.map((markerInfo) => markerInfo.op?.track)
.filter((trackId) => trackId !== undefined);
setTrackSections(await getTrackSectionsByIds(trackIds));
};

if (pathStepsAndSuggestedOPs) fetchTrackSections();
Expand Down

0 comments on commit c46f4a5

Please sign in to comment.