Browse Source

fix: Table drag demo (#30246)

pull/30249/head
叶枫 4 years ago
committed by GitHub
parent
commit
662c7bbf17
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      components/table/demo/drag-sorting.md

14
components/table/demo/drag-sorting.md

@ -24,8 +24,7 @@ const type = 'DragableBodyRow';
const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) => {
const ref = useRef();
const [{ isOver, dropClassName }, drop] = useDrop(
() => ({
const [{ isOver, dropClassName }, drop] = useDrop({
accept: type,
collect: monitor => {
const { index: dragIndex } = monitor.getItem() || {};
@ -40,19 +39,14 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
drop: item => {
moveRow(item.index, index);
},
}),
[index],
);
const [, drag] = useDrag(
() => ({
});
const [, drag] = useDrag({
type,
item: { index },
collect: monitor => ({
isDragging: monitor.isDragging(),
}),
}),
[index],
);
});
drop(drag(ref));
return (

Loading…
Cancel
Save