bc518174
王天杨
提交两个项目文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { useEffect, useMemo } from 'react'
import type { Connector } from '../../internals/index.js'
import type { DragSourceMonitor } from '../../types/index.js'
import type { DragSourceHookSpec } from '../types.js'
import { DragSourceImpl } from './DragSourceImpl.js'
export function useDragSource<O, R, P>(
spec: DragSourceHookSpec<O, R, P>,
monitor: DragSourceMonitor<O, R>,
connector: Connector,
) {
const handler = useMemo(
() => new DragSourceImpl(spec, monitor, connector),
[monitor, connector],
)
useEffect(() => {
handler.spec = spec
}, [spec])
return handler
}
|