Been struggling with this one for a few days now. On the quizzical solo project of the React course.
I want to conditionally update the quizArray state to reflect whether the user clicked the correct answer or not. I've tried this a number of ways (map, forEach, simple for loop) and each doesn't properly update state. Instead, the 'quizArray' state returns to it's previous value.
I've tried lazy state initialization and adding console.logs for every stateSetter to see if I was accidentally firing off any new renders, but nothing fires.
The "newArray" in the code below is always correct, but yet the state "quizArray" is never actually updated.
Would love any insight or help, perhaps there's a larger conceptual react piece that I'm missing here.
Code is too long to send in discord, so heres the github link.
https://github.com/JohnAlexR/scrimba-quizzical/tree/main/src
path is src/quiz. Function in question is called "selectAnswer" and state in question is 'quizArray'.
Thanks in advance as this has been driving me crazy!!