Skip to main content
The React adapter provides additional hooks for accessing the drag and drop manager, monitoring events, and tracking drag operations.

useDragDropManager

Access the DragDropManager instance from anywhere within a DragDropProvider.

Usage

Return Value

DragDropManager | null
The DragDropManager instance, or null if called outside a DragDropProvider.The manager provides access to:
  • dragOperation — Current drag operation state
  • registry — Registry of draggables and droppables
  • monitor — Event monitor for subscribing to events
  • plugins — Active plugins
  • sensors — Active sensors
  • modifiers — Active modifiers

Example

Type Parameters


useDragDropMonitor

Monitor drag and drop events from anywhere within a DragDropProvider. This hook subscribes to events and automatically cleans up listeners when the component unmounts.

Usage

Parameters

Partial<EventHandlers>
required
Object containing event handlers for drag and drop events. All handlers are optional.Available handlers:
  • onBeforeDragStart
  • onDragStart
  • onDragMove
  • onDragOver
  • onDragEnd
  • onCollision

Event Handlers

(event: BeforeDragStartEvent, manager: DragDropManager) => void
Called before a drag operation starts.
(event: DragStartEvent, manager: DragDropManager) => void
Called when a drag operation starts.
(event: DragMoveEvent, manager: DragDropManager) => void
Called continuously while dragging. Use sparingly as this fires frequently.
(event: DragOverEvent, manager: DragDropManager) => void
Called when dragging over a droppable element.
(event: DragEndEvent, manager: DragDropManager) => void
Called when a drag operation ends.
(event: CollisionEvent, manager: DragDropManager) => void
Called when collision detection identifies potential drop targets.

Examples

Event Logger

State Synchronization

Analytics Tracking


useDragOperation

Access the current drag operation state, including the drag source and target.

Usage

Return Value

Draggable | null
The draggable element currently being dragged, or null if no drag is active.
Droppable | null
The current drop target, or null if not over any droppable.

Examples

Drag Preview

Conditional Rendering

Global Drag Indicator

Type Parameters


Type Safety

All hooks support TypeScript generics for type-safe data: