I'm trying to push mouse position value into array and update on state.
If I stop moving mouse then the array get reset, so I want to store all values continuously with useState.

```
    const [route, setRoute] = useState("");

    let positionArray = [];

    const getMousePosition = (e) => {
        const position = {
            x: e.offsetX,
            y: e.offsetY,
        }
        positionArray.push(position);

        //setRoute([...positionArray, position])
    }

    useEffect(() => {
        window.addEventListener('mousemove', getMousePosition);
        return () => window.removeEventListener('mousemove', getMousePosition);
    })

```

I don't know what to do.. or is there any better idea? Thanks!