Created
March 21, 2021 12:49
-
-
Save yoavniran/6ef8750cf6ababefa7a855981429257d to your computer and use it in GitHub Desktop.
react-uploady usePasteUpload custom hook example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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