Back to React Dnd

useDrag

packages/docsite/markdown/docs/03 Using Hooks/useDragLayer.md

16.0.0882 B
Original Source
<!--alex disable hook -->

New to React DnD? Read the overview before jumping into the docs.

useDragLayer

The useDragLayer hook allows you to wire a component into the DnD system as a drag layer.

jsx
import { useDragLayer } from 'react-dnd'

function DragLayerComponent(props) {
  const collectedProps = useDragLayer(
    monitor => /* Collected Props */
  )
  return <div>...</div>
}

Parameters

  • collect: Required. The collecting function. It should return a plain object of the props to return for injection into your component. It receives two parameters, monitor and props. Read the overview for an introduction to the monitors and the collecting function. See the collecting function described in detail in the next section.

Return Value

An object of collected properties from the collect function.