Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
react-uploady usePasteUpload custom hook example
import React from "react";
import Uploady from "@rpldy/uploady";
import { usePasteUpload } from "@rpldy/upload-paste";
const ElementPaste = (props) => {
const containerRef = useRef(null);
const onPasteUpload = useCallback(({ count }) => {
console.log("ELEMENT PASTE-TO-UPLOAD files: ", count);
}, []);
const { toggle, getIsEnabled } = usePasteUpload(props, containerRef, onPasteUpload);
//toggle can be used in a button click handler to turn paste listening on/off
return <>
<div ref={containerRef}>
Click here & Paste a file
Paste is: {getIsEnabled() ? "enabled" : "disabled"}
</div>
</>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment