Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 869 Bytes

useDrop.md

File metadata and controls

49 lines (37 loc) · 869 Bytes

useDrop and useDropArea

Triggers on file, link drop and copy-paste.

useDrop tracks events for the whole page, useDropArea tracks drop events for a specific element.

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>
  );
};