Update Fix
This commit is contained in:
22
node_modules/react-dnd/src/hooks/useDrop/useDropTargetConnector.ts
generated
vendored
Normal file
22
node_modules/react-dnd/src/hooks/useDrop/useDropTargetConnector.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useMemo } from 'react'
|
||||
|
||||
import { TargetConnector } from '../../internals/index.js'
|
||||
import type { DropTargetOptions } from '../../types/index.js'
|
||||
import { useDragDropManager } from '../useDragDropManager.js'
|
||||
import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js'
|
||||
|
||||
export function useDropTargetConnector(
|
||||
options: DropTargetOptions,
|
||||
): TargetConnector {
|
||||
const manager = useDragDropManager()
|
||||
const connector = useMemo(
|
||||
() => new TargetConnector(manager.getBackend()),
|
||||
[manager],
|
||||
)
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
connector.dropTargetOptions = options || null
|
||||
connector.reconnect()
|
||||
return () => connector.disconnectDropTarget()
|
||||
}, [options])
|
||||
return connector
|
||||
}
|
||||
Reference in New Issue
Block a user