As the question above says, how can I empty an array? I tried using `useState` setting the array like this `setArray([])` but this actually doesn't not work properly because some times the array doesn't reset completly, is there another way to empty it?

Code:

```
const [array, setArray] = useState([]);
const functionName = (value) => {
        //reset the array first
        setArray([]);
        setArray([value]);
    }

```