diff --git a/webapp/src/components/Question.jsx b/webapp/src/components/Question.jsx index b52dd6a1..18e2707f 100644 --- a/webapp/src/components/Question.jsx +++ b/webapp/src/components/Question.jsx @@ -1,5 +1,6 @@ // Question.js import React, { useState, useEffect, useContext } from 'react'; +import { act } from 'react-dom/test-utils'; import { Card, List, ListItem, ListItemButton, ListItemText, Typography } from '@mui/material'; import { SessionContext } from '../SessionContext'; import correctSound from '../audio/correct.mp3'; @@ -139,17 +140,20 @@ const Question = ({ goTo, setGameFinished, gameMode, category, restart }) => { }); const data = await response.json(); - setQuestion(data.question); - setCorrect(data.correct); - setOptions(shuffleOptions([data.correct, ...data.incorrects])); + act(() => { + setQuestion(data.question); + setCorrect(data.correct); + setOptions(shuffleOptions([data.correct, ...data.incorrects])); - setSelectedOption(null); - setIsSelected(false); - setNQuestion((prevNQuestion) => prevNQuestion + 1); + setSelectedOption(null); + setIsSelected(false); + setNQuestion((prevNQuestion) => prevNQuestion + 1); + if (gameMode === "classic" || gameMode === "category") { handleClassicGameFinish(nQuestion, numberCorrect, numberIncorrect, segundos, sonido, goTo, setGameFinished); } + }); } catch (error) { console.error('Error fetching question:', error); }