Normally I can use this line to trigger the download of files:
<a href={require("../path/to/file.pdf")} download="myFile">Download file</a>
but when the file is plain text, for example a .txt file, when I click on the link the file is just opened in the browser to see the contents, is there a way to trigger the download of text files too?