Skip to content

Providing additional props in DragEndEvent #202

Discussion options

You must be logged in to vote

As of version ^3.0.0 of @dnd-kit/core, the data argument for useDraggable and useDroppable is now exposed in event handlers and on the active and over objects.

Example usage:

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

function Draggable() {
  const {attributes, listeners, setNodeRef, transform} = useDraggable({
    id: 'draggable',
    data: {
      type: 'type1',
    },
  });

  /* ... */
}

function Droppable() {
  const {setNodeRef} = useDroppable({
    id: 'droppable',
    data: {
      accepts: ['type1', 'type2'],
    },
  });

  /* ... */
}

function App() {
  return (
    <DndContext
      onDragEnd={({active, over}) => {
        if (over?.data.current.a…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@airtable-JayRansijn
Comment options

Comment options

You must be logged in to vote
1 reply
@growthwp
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
3 participants