how to append values to a state array in react

How do I append new value to the state array ?

I tried,

const [diabled, setDisabled] = useState([]);

const getValue = (id) => {
...
...
...
setDisabled(...disabled,id)
}

But doesn’t seems to work.

Answer

It should be spread inside an array:

Also, correct your spelling: disabled not diabled

setDisabled([...disabled,id])

And change your useState:

const [disabled, setDisabled] = useState([]);  // <-- Correct your spelling