From d4cdf2435fe62550274d60caaa17517cec14f169 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 14 Dec 2022 01:48:55 +0800 Subject: [PATCH] Fix poll percentage showing NaN This happens when votes are still 0, so 0 divide by 0 --- src/components/status.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index 16a738c7..fddcd472 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -287,7 +287,8 @@ function Poll({ poll }) { {voted || expired ? ( options.map((option, i) => { const { title, votesCount: optionVotesCount } = option; - const percentage = Math.round((optionVotesCount / votesCount) * 100); + const percentage = + Math.round((optionVotesCount / votesCount) * 100) || 0; return (