Skip to content

Commit e6c2d13

Browse files
committed
Handle null peak_mass_flow in map components
Updated Map and MapTooltip components to safely handle cases where 'peak_mass_flow' may be null or undefined. This prevents potential runtime errors and ensures consistent tooltip and layer rendering.
1 parent 1f5d6ae commit e6c2d13

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/features/map/components/Map/Map.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,15 @@ const useMapLayers = (onHover = () => {}) => {
220220
data: mapLayers[name]?.edges,
221221
getLineWidth: (f) =>
222222
normalizeLineWidth(
223-
f.properties['peak_mass_flow'],
223+
f.properties?.['peak_mass_flow'] ?? 0,
224224
min,
225225
max,
226226
1,
227227
7 * scale,
228228
),
229229
getLineColor: edgeColour,
230230
getDashArray: (f) =>
231-
f.properties['peak_mass_flow'] ? [0, 0] : [8, 4],
231+
f.properties?.['peak_mass_flow'] != null ? [0, 0] : [8, 4],
232232
dashJustified: true,
233233
dashGapPickable: true,
234234
extensions: [new PathStyleExtension({ dash: true })],

src/features/map/components/Map/MapTooltip.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,10 @@ const MapTooltip = ({ info }) => {
176176
? Math.round(Number(properties.pipe_DN) * 100) / 100
177177
: null;
178178

179-
const peakMassFlow = properties?.peak_mass_flow
180-
? Math.round(Number(properties.peak_mass_flow) * 1000) / 1000
181-
: null;
179+
const peakMassFlow =
180+
properties?.peak_mass_flow != null
181+
? Math.round(Number(properties.peak_mass_flow) * 1000) / 1000
182+
: null;
182183

183184
return (
184185
<div className="tooltip-content">

0 commit comments

Comments
 (0)