Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 859 Bytes

useDrop.md

File metadata and controls

48 lines (36 loc) · 859 Bytes

useDrop and useDropArea

触发文件,链接删除和复制粘贴。

useDrop跟踪整个页面的事件,useDropArea跟踪特定元素的拖放事件。

Usage

useDrop:

import {useDrop} from 'react-use';

const Demo = () => {
  const state = useDrop({
    onFiles: files => console.log('files', files),
    onUri: uri => console.log('uri', uri),
    onText: text => console.log('text', text),
  });

  return (
    <div>
      Drop something on the page.
    </div>
  );
};

useDropArea:

import {useDropArea} from 'react-use';

const Demo = () => {
  const [bond, state] = useDropArea({
    onFiles: files => console.log('files', files),
    onUri: uri => console.log('uri', uri),
    onText: text => console.log('text', text),
  });

  return (
    <div {...bond}>
      Drop something here.
    </div>
  );
};