React DnDReact DnD
  • 开始
  • 指南
⌘ K
主题
概述
教程
测试
FAQ
故障排除
组件
DndProvider
DragPreviewImage
Hooks
概述
useDrag
useDrop
useDragLayer
useDragDropManager
监控状态
DragSourceMonitor
DropTargetMonitor
DragLayerMonitor
后端
HTML5
后台
触摸
测试
最后更新时间:
帮助改进此文档
Made with ❤️ by Eric
‌
‌
‌
‌

useDragLayer

通过 useDragLayer 钩子,您可以将一个组件作为拖曳层连接到 DnD 系统中。

import { useDragLayer } from 'react-dnd'
function DragLayerComponent(props) {
const collectedProps = useDragLayer(
monitor => /* Collected Props */
)
return <div>...</div>
}

参数

  • collect: 必须填写。收集函数。它应返回一个纯道具对象,以便注入到组件中。它接收两个参数:monitor 和 props。请阅读概述以了解监控器和收集函数。下一节将详细介绍收集函数。

返回值

从收集函数中收集的属性对象。