@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
39 lines (34 loc) • 841 B
JavaScript
import { useMemo } from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
/**
* 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]);
}