Skip to content

How to access OnDrag events inside of draggable #268

Answered by clauderic
Logaqm asked this question in Q&A
Discussion options

You must be logged in to vote

The useDndMonitor hook can be used within components wrapped in a DndContext provider to monitor the different drag and drop events that happen for that DndContext.

import {DndContext, useDndMonitor} from '@dnd-kit/core';

function App() {
  return (
    <DndContext>
      <Component />
    </DndContext>
  );
}

function Component() {
  // Monitor drag and drop events that happen on the parent `DndContext` provider
  useDndMonitor({
    onDragStart(event) {},
    onDragMove(event) {},
    onDragOver(event) {},
    onDragEnd(event) {},
    onDragCancel(event) {},
  });
}

https://docs.dndkit.com/api-documentation/context-provider/use-dnd-monitor

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Logaqm
Comment options

Answer selected by clauderic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants