From 6d9a6a647e805ba1f2b699020138d622534c0347 Mon Sep 17 00:00:00 2001 From: Noam Levi Date: Sat, 31 Aug 2024 18:08:38 +0300 Subject: [PATCH] fixed reveal animation playing on first render --- src/components/WordsGuesser/index.tsx | 4 +++- src/main.tsx | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/WordsGuesser/index.tsx b/src/components/WordsGuesser/index.tsx index 21a9317..e1184c0 100644 --- a/src/components/WordsGuesser/index.tsx +++ b/src/components/WordsGuesser/index.tsx @@ -33,6 +33,7 @@ const WordsGuesser = () => { const isXs = useMediaQuery('(max-width: 400px)') const [selectedIdx, setSelectedIdx] = useState(undefined) const [shake, setShake] = useState(false) + const [isFirstGuessInSession, setIsFirstGuessInSession] = useState(true) const activeGuessIdx = guesses.length const lastGuess = guesses.at(-1) @@ -63,6 +64,7 @@ const WordsGuesser = () => { case 'Enter': if (numberOfEmptyLetters === 0) { if (isGuessInWordsSet && !isAlreadyGuess) { + setIsFirstGuessInSession(false) submitCurrentGuess() } else { setShake(true) @@ -186,7 +188,7 @@ const WordsGuesser = () => { guessedLetters={isActive ? currentGuess : guesses[idx]?.split('')} selectedIdx={isActive ? selectedIdx : undefined} onSelectIdx={isActive ? handleSelectIdx : undefined} - revealAnimation={idx === activeGuessIdx - 1} + revealAnimation={!isFirstGuessInSession && idx === activeGuessIdx - 1} /> ) diff --git a/src/main.tsx b/src/main.tsx index 7ff8a77..7ad77b8 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -41,7 +41,6 @@ const theme = createTheme({ createRoot(document.getElementById('root')!).render(