Mutating a new reference of a state array in order for React to register a change to said state has been made

PHOTO EMBED

Fri May 20 2022 16:19:51 GMT+0000 (Coordinated Universal Time)

Saved by @Floony #javascript

function addVote() {
    const newVotes = [...votes];
    newVotes[selected] += 1;
    setSelected(selected);
    setVotes(newVotes);
  }
content_copyCOPY

https://stackoverflow.com/questions/70104545/react-ui-not-updating-although-im-changing-the-state