react drag and drop image upload code example
Example 1: drag n drop file upload react
<FileDrop
onTargetClick={onTargetClick}
Example 2: drag n drop file upload react
const fileInputRef = useRef(null);
Example 3: drag n drop file upload react
<input
onChange={onFileInputChange}
ref={fileInputRef}
type="file"
className="hidden"
/>
Example 4: drag n drop file upload react
const onFileInputChange = (event) => {
const { files } = event.target;
}
Example 5: drag n drop file upload react
const onTargetClick = () => {
fileInputRef.current.click()
}