I don't understand completely the benefit of using oldState / prevState. In the tutorial the code was changed from this :
const DeleteClick = (id) => {
SetMylist(Elems.filter(Elem => id !== Elem.id))
}
to this :
const DeleteClick = (id) => {
SetMylist(OldElems => {
return OldElems.filter(Elem => id !== Elem.id)
})
}
The guy said in the tutorial that if we use oldState / prevState then we get the most recent ( updated ) version of the state variable.
You will be able to learn what the difference between setState and prevState is and what the benefit of prevState is from https://www.delftstack.com/howto/react/react-setstate-prevstate/#:~:text=setState%20is%20the%20primary%20method,that%20component%2C%20we%20use%20this.