Display PDF in reactJS
it looks like you're passing the PDF data directly to the <ReactPDF>
component as the value of the file
prop. But according to the docs you need to use an object containing a data
property:
<ReactPDF
file={{
data: renderPdf
}}
/>
it seems you can also set file
to an object containing a url
property, to let ReactPDF fetch the pdf from your backend by itself, if that's easier:
<ReactPDF
file={{
url: 'http://www.example.com/sample.pdf'
}}
/>
Try this
<object width="100%" height="400" data="http://www.africau.edu/images/default/sample.pdf" type="application/pdf"> </object>
If you goal is just to view the pdf in your application, the easiest way is using the object tag in HTML. You don't need to import any libraries and works most of the browsers. But this is lack of customization and styles.
<object data="http://africau.edu/images/default/sample.pdf" type="application/pdf" width="100%" height="100%">
<p>Alternative text - include a link <a href="http://africau.edu/images/default/sample.pdf">to the PDF!</a></p>
</object>