Skip to content
Compare
Choose a tag to compare
@github-actions github-actions released this 20 Apr 02:23
· 292 commits to master since this release
98a3a46

Major Changes

  • a9d92cf #174 Thanks @clauderic! - Distributed assets now only target modern browsers. Browserlist config:

    defaults
    last 2 version
    not IE 11
    not dead
    

    If you need to support older browsers, include the appropriate polyfills in your project's build process.

  • b406cb9 #187 Thanks @clauderic! - Introduced the useDndMonitor hook. 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.

    Example usage:

    import {DndContext, useDndMonitor} from '@dnd-kit/core';
    
    function App() {
      return (
        <DndContext>
          <Component />
        </DndContext>
      );
    }
    
    function Component() {
      useDndMonitor({
        onDragStart(event) {},
        onDragMove(event) {},
        onDragOver(event) {},
        onDragEnd(event) {},
        onDragCancel(event) {},
      });
    }

Minor Changes

  • b7355d1 #207 Thanks @clauderic! - 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.accepts.includes(active.data.current.type)) {
              // do stuff
            }
          }}
        />
      );
    }

Patch Changes