Check out example codes for "how to set a var in js to be a download". It will help you in understanding the concepts better.

Code Example 1

var textToSave = 'this is a test';

var hiddenElement = document.createElement('a');

hiddenElement.href = 'data:attachment/text,' + encodeURI(textToSave);
hiddenElement.target = '_blank';
hiddenElement.download = 'myFile.txt';
hiddenElement.click();

Learn ReactJs, React Native from akashmittal.com