нужно игнорировать вопрос, если UUID уже завершен в завершенных вопросах и переходить к следующему вопросу. Автоинкремент не работает, когда я использую this.setState ({autoIncrement: this.state.autoIncrement + 1}), чтобы пропустить к следующему вопросу
вот мои переменные конструктора
const = randomQuestions:[{
"uuid": "sjdfhgs-wer-1231456",
"question": "What is Lorem Ipsum?",
"options": ["a", "b", "c"],
"currectAns": "a"
},
{
"uuid": "sjdfhgs-wer-1241235",
"question": "Why do we use it?",
"options": ["a", "b", "c"],
"currectAns": "b"
},
{
"uuid": "sjdfhgs-wer-1233233",
"question": "Where does it come from?",
"options": ["a", "b", "c"],
"currectAns": "a"
},
{
"uuid": "sjdfhgs-wer-1243453",
"question": "Where can I get some?",
"options": ["a", "b", "c"],
"currectAns": "c"
}
],
const = autoIncrement:0,
const = completedQuestions:["sjdfhgs-wer-1233233"]
вот мои две функции
generateQuestion(){ //here is my Question generation Function
if(!completedQuestions.includes(randomQuestions[autoIncrement].uuid)){
this.state.completedQuestions.push(randomQuestions[autoIncrement].uuid) //it will add after choosing the answer
this.setState({autoIncrement:this.state.autoIncrement+1})
}else{
this.generateNextQuestion(); //skip to next Question if randomQuestions UUID includes in completedQuestions
}
}
generateNextQuestion(){
this.setState({autoIncrement:this.state.autoIncrement+1}) //this is not working
this.generateQuestion()
}