From 31234ed027900e6b69ae4bf8b35cc23ffdda6524 Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Sat, 6 Aug 2022 14:32:13 -0500 Subject: [PATCH] rename game ref --- squarenotsquare/src/screens/Game.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/squarenotsquare/src/screens/Game.js b/squarenotsquare/src/screens/Game.js index cac52ab..ab44a1d 100644 --- a/squarenotsquare/src/screens/Game.js +++ b/squarenotsquare/src/screens/Game.js @@ -21,7 +21,7 @@ function Game(props){ const [timerState, setTimerState] = useState(0); const localTimer = useRef(null); const startTime = useRef(0); - const score = useRef(0); + const answers = useRef(0); const [scrollOrigin, setScrollOrigin] = useState(0); const scrollDestination = useRef(Metrics.animated.gameScrollInterval); const [headerText, setHeaderText] = useState('Ready?'); @@ -80,7 +80,7 @@ function Game(props){ function selectAnswer(pairIndex, correct){ if (pairIndex === challengeState.current){ if (correct) { - score.current = score.current + 1; + answers.current = answers.current + 1; } let newOrigin = scrollDestination.current; @@ -102,9 +102,7 @@ function Game(props){ setHeaderColor(styles.darkGreen); setHeaderText(finalTime + ' s'); setTimerState(4); - setTimeout(() => { - dispatch(squareFinished(score.current, finalTime)); - }, 3000); + dispatch(squareFinished(answers.current, finalTime)); } function generateSquare(pairIndex){ @@ -194,7 +192,7 @@ function Game(props){ - {score.current + ' / ' + squareChallenge.current.length} + {answers.current + ' / ' + squareChallenge.current.length}