-
in driveFiles I am getting multiple file names. - for each attachment I need to attach pdf or word or jpg icon - so I used substr and lastIndexOf got the file formats. - now using if conditions I am able to disable icon for one files. - if I test for more than one files, its not checking for second if. - I think the problem is due to the return statement in first if. - can you tell me how to fix it for multiple files. - providing my code snippet below.
<!-- language-all: lang-or-tag-here --> {this.props.driveFiles.length > 0 ? this.props.driveFiles.map(_driveFileKey => { var driveFormat = _driveFileKey.name.substr( _driveFileKey.name.lastIndexOf(".") + 1 ); console.log("filename--->", driveFormat); if (driveFormat === "pdf") { return ( <div> {" "} <Icon icon={["fal", "file-pdf"]} /> {_driveFileKey.name} </div> ); } else if (driveFormat === "doc") { return ( <div> {" "} <Icon icon={["fal", "file-word"]} /> {_driveFileKey.name} </div> ); } else if (driveFormat === "jpg") { return ( <div> {" "} <Icon icon={["fal", "file-image"]} /> {_driveFileKey.name} </div> ); } //return <div>{_driveFileKey.name}</div>; }) : ""}
from each attachment I need to attach pdf or word or jpg icon
No comments:
Post a Comment