Skip to content

Commit

Permalink
Make DragLayerMonitor generic (#3341)
Browse files Browse the repository at this point in the history
* Make DragLayerMonitor generic

* fix: remove files deleted in main

Co-authored-by: Chris Trevino <chtrevin@microsoft.com>
  • Loading branch information
TheHaff and darthtrevino committed Feb 3, 2022
1 parent 5c18e70 commit d01796c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/react-dnd/src/hooks/useDragLayer.ts
Expand Up @@ -7,8 +7,8 @@ import { useCollector } from './useCollector'
* useDragLayer Hook
* @param collector The property collector
*/
export function useDragLayer<CollectedProps>(
collect: (monitor: DragLayerMonitor) => CollectedProps,
export function useDragLayer<CollectedProps, DragObject = any>(
collect: (monitor: DragLayerMonitor<DragObject>) => CollectedProps,
): CollectedProps {
const dragDropManager = useDragDropManager()
const monitor = dragDropManager.getMonitor()
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dnd/src/types/monitors.ts
Expand Up @@ -158,7 +158,7 @@ export interface DropTargetMonitor<DragObject = unknown, DropResult = unknown>
getSourceClientOffset(): XYCoord | null
}

export interface DragLayerMonitor {
export interface DragLayerMonitor<DragObject = unknown> {
/**
* Returns true if a drag operation is in progress. Returns false otherwise.
*/
Expand All @@ -175,7 +175,7 @@ export interface DragLayerMonitor {
* Every drag source must specify it by returning an object from its beginDrag() method.
* Returns null if no item is being dragged.
*/
getItem(): any
getItem<T = DragObject>(): T

/**
* Returns the { x, y } client offset of the pointer at the time when the current drag operation has started.
Expand Down

0 comments on commit d01796c

Please sign in to comment.