I want to clear all data in a state that contains a list of items:
const [items, setItems] = useState([]);
When I try the code below, and add items in it again, it doesn't clear the state as expected:
setItems([]);
var newItem = {
...
}
setItems([...items, newItem])
What did I missed?