To delete element from an array without mutating the state I write this code below which work fine
const tmp = [ ...array ]
tmp.splice(i, 1)
setArray(tmp)
I played a little bit with the code and i try this
array.splice(i, 1)
setArray([ ...array ])
But I got a weird behavior in the UI.
So What is wrong with this code, because i think i am not mutating the state, am I ?