-
I have a variable list of draggables im rendering, how can i access the onDrag events in the draggables component, rather than on the dndcontext? It would be much easier if they were able to listen to this event and update their own transform. |
Beta Was this translation helpful? Give feedback.
Answered by
clauderic
May 12, 2021
Replies: 1 comment 1 reply
-
The 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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
clauderic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.https://docs.dndkit.com/api-documentation/context-provider/use-dnd-monitor