Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DragLayerMonitor generic #3341

Merged
merged 3 commits into from Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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