Skip to content

Commit 2fc9b4b

Browse files
committed
fix the of displaying NaN when the metric value is not a number
1 parent f186970 commit 2fc9b4b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/app/components/StateRoute.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ const StateRoute = (props: StateRouteProps) => {
137137

138138
return (
139139
<div className="web-metrics-container">
140-
<WebMetrics color={LCPColor} series={(webMetrics.LCP / 2500) * 100} formatted={(val) => ((val / 100) * 2500).toFixed(2) + ' ms'} label="LCP"/>
141-
<WebMetrics color={FIDColor} series={(webMetrics.FID) * 25} formatted={(val) => ((val / 25)).toFixed(2) + ' ms'} label="FID"/>
142-
{/* <WebMetrics color={CLSColor} series={(webMetrics.CLS * 50) * 100} formatted={(val) => ((val / 100) / 50).toFixed(2)} label="CLS"/> */}
140+
<WebMetrics color={LCPColor} series={(webMetrics.LCP / 2500) * 100}
141+
formatted={(val) => { return (Number.isNaN(val)) ? '-- ms' : (((val / 100) * 2500).toFixed(2) + ' ms')}}
142+
label="LCP" />
143+
<WebMetrics color={FIDColor} series={(webMetrics.FID) * 25}
144+
formatted={(val) => { return (Number.isNaN(val)) ? '-- ms' : ((val / 25).toFixed(2) + ' ms')}}
145+
label="FID" />
143146
<WebMetrics color={FCPColor} series={(webMetrics.FCP / 1000) * 100} formatted={(val) => ((val / 100) * 1000).toFixed(2) + ' ms'} label="FCP"/>
144147
<WebMetrics color={TTFBColor} series={(webMetrics.TTFB / 10) * 100} formatted={(val) => ((val / 100) * 10).toFixed(2) + ' ms'} label="TTFB"/>
145148
</div>

0 commit comments

Comments
 (0)