React Hookers - v6.3.0
    Preparing search index...

    Function useDrag

    • Handles the drag behavior across platforms.

      Parameters

      Returns DragValue

      An object which identity never changes between renders.

      const targetRef = useRef(null);

      const { dragProps, isDragged } = useDrag({
      onDrag(info) {
      targetRef.current.style.inset = `${info.y}px auto auto ${info.x}px`;
      }
      });

      <div
      {...dragProps}
      ref={targetRef}
      style={{
      position: 'absolute',
      width: 100,
      height: 100,
      backgroundColor: isDragged ? 'red' : 'blue',
      }}
      />