Here is my code. Webpack loads the PDF alright. The react component does not render the pdf. When accessing through the react component it brings a blank page with page no. 1 of When put the following url in the browser it renders the pdf from browser directly and is alright.
http://localhost:3000/bfa955d1b47a762fb2b4d8cc2525f637.pdf
import React, {Component} from "react";
import myPdf from '../images/BSOAANZChapterConstitution.pdf'
import {Document, Page} from 'react-pdf/build/entry.webpack';
class Constitution extends Component {
constructor(props) {
super(props);
this.state = {
numPages: null,
pageNumber: 1
};
}
onDocumentLoad({numPages}) {
this.setState({numPages});
}
render() {
const {pageNumber, numPages} = this.setState;
return (
<div>
<Document
file={myPdf} onLoadSuccess={this.onDocumentLoad}>
<Page pageNumber={pageNumber}/>
</Document>
<p>Page {pageNumber} of {numPages}</p>
</div>
);
}
}
export default Constitution;