admin管理员组文章数量:1122832
In this handleFileEvent function when selecting multiple files it should display the message "Multiple Files Not Allowed" but not sure why the message is not displaying.
const handleFileEvent = (e: any) => {
const chooseFiles = Array.from(e.target.files);
if (chooseFiles.length > 1) {
ShowToastMessage('Warning', "Can't choose multiple files");
} else {
handleUploadFiles(chooseFiles);
e.target.value = '';
console.log(chooseFiles);
}
}
const handleUploadFiles = (files: any) => {
const uploaded = [...uploadfile]
files.some((file: any) => {
const fileName = file.name.toLowerCase()
const fileExtension = fileName.slice(((fileName.lastIndexOf('.') - 1) >>> 0) + 2)
if (allowedExtensions.includes(fileExtension)) {
if (uploaded.findIndex((f: any) => f.name === file.name) === -1) {
uploaded.push(file)
}
} else {
ShowToastMessage(
'Warning',
`${file.name} is not allowed. Allowed extensions: 3gp,aac,act,aiff,amr,ape,au,avi,awb,bdvm,bmp,dat,dct,dds,dib,doc,docx,dss,dvf,dvr-ms,eml,flac,flv,gif,gsm,html,ifo,iklax,ivs,jfif,jpe,jpeg,jpg,m2ts,m4a,m4p,m4v,mht,mkv,mmf,mov,mp3,mp4,mpc,mpeg,mpg,msg,msv,mts,oga,ogg,ogm,ogv,opus,pdf,pjpeg,png,pps,ppt,pptx,qt,ra,raw,rm,rtf,sbe,sln,tga,tif,tiff,ts,tta,txt,vox,wav,webm,wma,wmv,wtv,wv,xls,xlsx,x-png,csv`,
ToastMessageType.Warning,
)
}
})
const e = { ...gridHelper.entities }
e['uploadfiles'] = uploaded
gridHelper.setEntities(e)
setUploadfiles(uploaded)
}
本文标签: reactjsthe Toast message in the given function is not showning in the UIStack Overflow
版权声明:本文标题:reactjs - the Toast message in the given function is not showning in the UI - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311100a1934617.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论