function handleinputchange(e) {
if (timetaken)
return;
if (starttime === 0) {
start();
}
if (string === e.target.value) {
setinputvalue("");
console.log("Now we will change the i =", typeof (i));
seti(prevIndex => prevIndex + 1);
console.log("Changed value of i is ,", i);
setstring(data[i].text);
console.log("Now the changed string is ", string);
return;
}
// if (e.target.value.length === 49)
// setinputvalue(inputvalue + " ")
if (!string.startsWith(e.target.value)) {
setwrong(true);
setTimeout(() => setwrong(false), 500);
setincorrect(incorrect + 1);
return;
}
setinputvalue(e.target.value);
setcorrect(correct + 1);
}
In this function on this line
seti(prevIndex => prevIndex + 1);
You did not check if the prevIndex is a number or not. So when the code was getting executed on this line the prevIndex was getting set as String instead of a number.
There was a small mistake in your code.
in
App.js
You had writtenIn this function on this line
You did not check if the prevIndex is a number or not. So when the code was getting executed on this line the prevIndex was getting set as String instead of a number.
So I solved it like