In my react component I have a function which use file-saver package to save an array of files.
File-saver package installation:
npm i file-saver
My react component:
import { saveAs } from 'file-saver'
saveImg(urlArr){
urlArr[0];
let name = 'img' + 0 + '.jpg';
saveAs(urlArr[0], name)
urlArr[2];
let name2 = 'img' + 2 + '.jpg';
saveAs(urlArr[2], name2)
}
, and it works but my expectation was downloading files instead of opening images in new browser tabs. I would like to trigger downloading from react component. How to force downloading? What are others libraries used for downloading?