<input
onChange={onFileInputChange}
ref={fileInputRef}
type="file"
className="hidden"
/>
<FileDrop
onTargetClick={onTargetClick}
//Put it in a function (worked for me)
function DragDrop() {
const [file, setFile] = useState(null);
const handleChange = file => {
setFile(file);
};
return (
<FileUploader
handleChange={handleChange}
name="file"
/>
);
}
//And call it e.g.
return (
...
<DragDrop/>
...
)
const fileInputRef = useRef(null);
const onFileInputChange = (event) => {
const { files } = event.target;
// do something with your files...
}
const onTargetClick = () => {
fileInputRef.current.click()
}
nvm use # Probably optional, but it can't hurt
cd file-drop
npm install
npm start
cd demo
npm install
npm start