diff --git a/ViewGraph.tsx b/ViewGraph.tsx index e5516a1..ef83df2 100644 --- a/ViewGraph.tsx +++ b/ViewGraph.tsx @@ -26,9 +26,11 @@ export default function ViewGraph() { const [unit, setUnit] = useState('kg'); const convertWeight = (weight: number, unitFrom: string, unitTo: string) => { - if (unitFrom === unitTo) return weight; - if (unitFrom === 'lb' && unitTo === 'kg') return weight * 0.453592; - if (unitFrom === 'kg' && unitTo === 'lb') return weight * 2.20462; + let result = weight; + if (unitFrom === unitTo) result = weight; + if (unitFrom === 'lb' && unitTo === 'kg') result = weight * 0.453592; + if (unitFrom === 'kg' && unitTo === 'lb') result = weight * 2.20462; + return isNaN(result) ? 0 : result; }; useEffect(() => {