I have a window `mousemove` event listener, that calls a function that changes a variable. However when I assign the varibale to a prop it doesn't change:

```
  var x = null
  var y = null

  const cursor = (e) => {
    x = e.screenX + 'px'
    y = e.screenY + 'px'
    console.log(x, y)
    return x, y
  }

  window.addEventListener('mousemove', cursor)

```

I tried to directly change it in the event listener

(`window.addEventListener('mousemove', //everything in cursor`) but then I wouldn't be able to access the `e` variable. 

I also can't use it with state because for some reason it's gets too laggy and crashes.

How can I make this work? Thanks in advance.

That's what I see in vscode:

[![enter image description here](https://i.stack.imgur.com/yPyTC.png)](https://i.stack.imgur.com/yPyTC.png)

(This is in the App component, the variables and the evenet listener are in the App too.)

Sandbox: <https://codesandbox.io/s/vigorous-agnesi-9l1ic?file=/src/App.js>