From 1bdcab6bbffe76aed8600d2f77f1a6b33c824382 Mon Sep 17 00:00:00 2001 From: nczitzk <42264778+nczitzk@users.noreply.github.com> Date: Sat, 24 Sep 2022 22:25:48 +0800 Subject: [PATCH] fix(typebox): WPM is NaN when there is no effective wpm --- src/components/features/TypeBox/TypeBox.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/features/TypeBox/TypeBox.js b/src/components/features/TypeBox/TypeBox.js index 53cf99e..066bfdb 100644 --- a/src/components/features/TypeBox/TypeBox.js +++ b/src/components/features/TypeBox/TypeBox.js @@ -325,10 +325,12 @@ const TypeBox = ({ textInputRef, isFocusedMode, handleInputFocus }) => { return; } - // update stats when typing - const currWpm = - (wpmKeyStrokes / 5 / (countDownConstant - countDown)) * 60.0; - setWpm(currWpm); + // update stats when typing unless there is no effective wpm + if (wpmKeyStrokes !== 0) { + const currWpm = + (wpmKeyStrokes / 5 / (countDownConstant - countDown)) * 60.0; + setWpm(currWpm); + } // start the game by typing any thing if (status !== "started" && status !== "finished") {