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

37 lines (34 loc) 852 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`. */ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports export function useDroppableData({ contextId, droppableId, getIsDropDisabled }) { return useMemo(() => { return { [privateKey]: true, contextId, droppableId, getIsDropDisabled }; }, [contextId, droppableId, getIsDropDisabled]); }