title: React hooks set start position of touch event
body: <p>I'm having difficulty setting the start position of a touch event. It seems to set one position, then keep it forever.</p>
  
  <p>The desired behaviour is that, if I swipe upwards, the number increments by one, and if I swipe downwards, the count decrements by one.</p>
  
  <p>In particular, this function does not work:</p>
  
  <pre><code>  const handleTouchMove = useCallback(
      (event) =&gt; {
        console.log(touchState.touchStartYPosition, event.touches[0].clientY, touchState.touchYPosition)
        if (touchState.isDragging === true &amp;&amp; event.touches[0].clientY) {
          if (!touchState.touchStartYPosition) {
            setTouchState(prevTouchState =&gt; ({
              ...prevTouchState,
              touchStartYPosition: event.touches[0].clientY - 50
          }));
          } else {
            if (event.touches[0].clientY - touchState.touchStartYPosition &gt;= 0) {
              setTouchState(prevTouchState =&gt; ({
                ...prevTouchState,
                touchYPosition: touchState.touchYPosition + 1
            }));
            }
          }
        }
  }, [touchState.isDragging, touchState.touchYPosition]
    );
  </code></pre>
  
  <p>How can I compare the current touch position to the starting touch position?</p>
  
  <p><a href="https://codesandbox.io/s/davtho-e47s4" rel="nofollow noreferrer">New codeandbox</a></p>