Through dropzone, I'm uploading or dropping files. What I want to do is to open a new window type, based on the file type that has been dropped. To accomplish this, I'm trying to use the useEffect hook. But it doesn't produce any error and doesn't work:
const [win, setWin] = useState("A-Type");
let accepted_file = acceptedFiles[0];
useEffect(() => {
function handleSecondWindowType () {
if (accepted_file.type.includes('image/')) {
setWin("A-Type")
}
else {
setWin("B-Type");
}
}
},[accepted_file]);
Looks like you have created an internal function but forgot to call it. You have to call it or nothing happened:
useEffect(() => {
// call it
handleSecondWindowType();
function handleSecondWindowType () {
if (accepted_file.type.includes('image/')) {
setWin("A-Type")
}
else {
setWin("B-Type");
}
}
},[accepted_file]);