0

I'm coding a quiz with the expo framework, in a certain part of the code I make a comparison of each answer chosen by the user. It works for all questions except the first one. The part that compares is down below:

const verificarResposta = (opMarcada, opCorreta) => {
    console.log("choosen: ", opMarcada, " correct: ", opCorreta)
    // compares the choosen option with the right value
    if (opMarcada == opCorreta) {
      setAcertos(acertos => acertos+1)
      console.log("correct! ", acertos)
    } else {
      setErros(erros => erros+1)
      console.log("wrong! ", erros)
    }
    proximaQuestao()
  }

I tried to increase both the number of hits and misses, for all it works with the exception of the first increment. hope it works for all comparisons.

  • 1
    Does this answer your question? [The useState set method is not reflecting a change immediately](https://stackoverflow.com/questions/54069253/the-usestate-set-method-is-not-reflecting-a-change-immediately) – Konrad Apr 09 '23 at 22:50

0 Answers0