Blame view

天文台pc/tianwentai-ui/node_modules/react-dnd/src/hooks/useDrop/useDropTarget.ts 486 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  import { useEffect, useMemo } from 'react'
  
  import type { DropTargetMonitor } from '../../types/index.js'
  import type { DropTargetHookSpec } from '../types.js'
  import { DropTargetImpl } from './DropTargetImpl.js'
  
  export function useDropTarget<O, R, P>(
  	spec: DropTargetHookSpec<O, R, P>,
  	monitor: DropTargetMonitor<O, R>,
  ) {
  	const dropTarget = useMemo(() => new DropTargetImpl(spec, monitor), [monitor])
  	useEffect(() => {
  		dropTarget.spec = spec
  	}, [spec])
  	return dropTarget
  }