#StackBounty: #javascript #html #css #reactjs #redux each attachment I need to attach pdf or word or jpg icon

Bounty: 50

  • 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 (
                                
    {" "} {_driveFileKey.name}
    ); } else if (driveFormat === "doc") { return (
    {" "} {_driveFileKey.name}
    ); } else if (driveFormat === "jpg") { return (
    {" "} {_driveFileKey.name}
    ); } //return
    {_driveFileKey.name}
    ; }) : ""}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.