I am trying to build a single page app using React. I came up with this hacky way to download a local file (residing in the public
directory). I have two questions:
- Can I write this more cleanly?
- Is there any better or more elegant way to download a local file?
const handleDownload = () => {
const tempComponent = document.createElement('a')
tempComponent.href = 'Dark.ask'
tempComponent.download = 'Dark.ask'
tempComponent.click()
tempComponent.parentElement?.removeChild(tempComponent)
}