How to use the react-dnd.useDragLayer function in react-dnd

To help you get started, we’ve selected a few react-dnd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / Spoke / src / ui / dnd / DragLayer.js View on Github external
export default function DragLayer() {
  const { item, itemType, currentOffset, isDragging } = useDragLayer(monitor => ({
    item: monitor.getItem(),
    itemType: monitor.getItemType(),
    currentOffset: monitor.getClientOffset(),
    isDragging: monitor.isDragging()
  }));

  if (!isDragging || !currentOffset) {
    return null;
  }

  let preview;

  if (itemType === ItemTypes.Node) {
    if (item.multiple) {
      preview = <div>{`${item.value.length} Nodes Selected`}</div>;
    } else {