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.
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.
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