UNPKG

@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration

Version:

An optional Pragmatic drag and drop package that enables rapid migration from react-beautiful-dnd to Pragmatic drag and drop

36 lines (33 loc) 777 B
import { useMemo } from 'react'; /** * Private symbol that is intentionally not exported from this file. */ const privateKey = Symbol('DroppableData'); /** * Data that is attached to drags. */ /** * Checks if the passed data satisfies `DroppableData` using the private symbol. */ export function isDroppableData(data) { return data[privateKey] === true; } /** * Adds the private symbol to the passed data. * * The symbol allows us to quickly check if an object satisfies `DroppableData`. */ export function useDroppableData({ contextId, droppableId, getIsDropDisabled }) { return useMemo(() => { return { [privateKey]: true, contextId, droppableId, getIsDropDisabled }; }, [contextId, droppableId, getIsDropDisabled]); }