diff --git a/src/App.js b/src/App.js index 8b1f233..d994df1 100644 --- a/src/App.js +++ b/src/App.js @@ -48,7 +48,7 @@ function App() { document.title = titleAPP.spanish } - }) + }, []) if (isVictory || isDefeat) { diff --git a/src/components/Hangman/PuzzleWord/PuzzleWord.jsx b/src/components/Hangman/PuzzleWord/PuzzleWord.jsx index df749ae..5261b3d 100644 --- a/src/components/Hangman/PuzzleWord/PuzzleWord.jsx +++ b/src/components/Hangman/PuzzleWord/PuzzleWord.jsx @@ -30,21 +30,7 @@ const PuzzleWord = ({hangmanFrame, setHangmanFrame, currentScore, setCurrentScor puzzleWord.appendChild(counter) } - const definePuzzle = async () => { - const words = await BringTheWords(language, category) - const wordSelection = await SelectRandomWord(words) - - const word = await words[wordSelection] - - await setActualWord(word) - - } - if (!displayApp && !actualWord) { - - definePuzzle() - } - if (actualWord && !displayApp) { @@ -58,6 +44,23 @@ const PuzzleWord = ({hangmanFrame, setHangmanFrame, currentScore, setCurrentScor React.useEffect(() => { + const definePuzzle = async () => { + + const words = await BringTheWords(language, category) + const wordSelection = await SelectRandomWord(words) + + const word = await words[wordSelection] + + setActualWord(word) + + } + + if (!displayApp && !actualWord) { + + definePuzzle() + } + + if (displayApp) { Register_Input(actualWord, hangmanFrame, setHangmanFrame, setIsVictory, setIsDefeat)