I
I
Ivan Smirnov2018-02-08 09:14:05
JavaScript
Ivan Smirnov, 2018-02-08 09:14:05

How to open documents by clicking on a link in React JS?

Hello, there is a problem, when you click on the link , you need to open the pdf catalog , if nothing comes out through a href="file//address of the File in the Component Folder" and the build is empty , I don’t understand how to implement this at all, help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Zharov, 2018-02-08
@SeaBreeze876

the catalog file must be in the directory where the static is hosted from, a local link to the file will not work.
The most convenient option is to add a file-loader to the collector config, specify the link as href=require('path_to_pdf'). The builder itself will move the file to the build directory and replace "require" with a link to it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question