I am fundamentally misunderstanding React hooks, especially the useState function. Why doesn't the code below update the index of the old array, and instead set the value of trick to 1? I understand how to push a new item onto an array with React hooks, but how do you update existing values?
const [trick, modifyTrick] = useState([null, null, null, null]);
const identityTrick = () => {
modifyTrick(oldTrick => oldTrick) //works
}
const updatedTrick = () => {
modifyTrick(oldTrick => oldTrick[0] = 1) //sets the entire value of trick to 1
}