Skip to content

Instantly share code, notes, and snippets.

@chris-feist
Last active June 28, 2019 22:11
Show Gist options
  • Save chris-feist/5d5b62ff261556c9ed059a1e73b18a2a to your computer and use it in GitHub Desktop.
Save chris-feist/5d5b62ff261556c9ed059a1e73b18a2a to your computer and use it in GitHub Desktop.
React Hooks: useWindowDropZone.js onDrop
import { useEffect } from 'react';
export default (args) => {
const {
onDrop,
} = args;
useEffect(() => {
window.addEventListener('drop', onDrop);
return () => {
window.removeEventListener('drop', onDrop);
};
}, [onDrop]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment