lundi 26 juillet 2021

React : Link to PDF which is in my project folder

In my React application, I want to link to a PDF from a page.

The PDF is located in src\assets\, and I have my component in src\components\xyz\.

In my component, I simply do <a href="<link to pdf>" >Download here</a>, but clicking on this takes me to localhost:3000/foo.pdf which doesn't give me anything.

When I add a download attribute to a it downloads the file, but I want it to first open in a new tab and then the user can download it from there.

How do I achieve this?




Aucun commentaire:

Enregistrer un commentaire