Documentation
Hooks
useDragAndDrop

useDragAndDrop

Handle the user drag actions on a container element.

Drag

Type Definitions

type DragAction = {
    type: 'start' | 'moving' | 'end';
    clientX: number;
    clientY: number;
    initialX: number;
    initialY: number;
    target: EventTarget;
    event: PointerEvent;
};
type DragActionHandler = (action: DragAction) => any;
 
const useDragAndDrop: <T extends HTMLElement = HTMLDivElement>(args: {
    handler: DragActionHandler;
    ref?: React.RefObject<T> | null;
}) => React.RefObject<T>;