repo_description: Beautiful and accessible drag and drop for lists with React
repo_topics: dnd drag drag-and-drop react reordering sortable
code: // @flow
  import memoizeOne from 'memoize-one';
  import { values } from '../native-with-fallback';
  import type {
    DroppableDimension,
    DroppableDimensionMap,
    DraggableDimension,
    DraggableDimensionMap,
  } from '../types';
  
  export const toDroppableMap = memoizeOne(
    (droppables: DroppableDimension[]): DroppableDimensionMap =>
      droppables.reduce((previous, current) => {
        previous[current.descriptor.id] = current;
        return previous;
      }, {}),
  );
  
  export const toDraggableMap = memoizeOne(
    (draggables: DraggableDimension[]): DraggableDimensionMap =>
      draggables.reduce((previous, current) => {
        previous[current.descriptor.id] = current;
        return previous;
      }, {}),
  );
  
  export const toDroppableList = memoizeOne(
    (droppables: DroppableDimensionMap): DroppableDimension[] =>
      values(droppables),
  );
  
  export const toDraggableList = memoizeOne(
    (draggables: DraggableDimensionMap): DraggableDimension[] =>
      values(draggables),
  );
  