Skip to content

Commit 167f0cd

Browse files
committed
Code cleanup
1 parent 4b5379f commit 167f0cd

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Pdf.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,10 @@ class Pdf extends React.Component {
1515
this.renderPdf();
1616
}
1717

18-
// Not sure... Would this helpful?
19-
// componentWillUnmount() {
20-
// const {pdf} = this.state;
21-
// pdf.destroy();
22-
// }
23-
2418
componentWillReceiveProps(newProps) {
2519
const { pdf } = this.state;
2620

27-
// Only reload iff the most significant source
28-
// has changed!
21+
// Only reload if the most significant source has changed!
2922
let newSource = newProps.file;
3023
let oldSource = newSource ? this.props.file : null;
3124
newSource = newSource || newProps.binaryContent;
@@ -44,6 +37,11 @@ class Pdf extends React.Component {
4437
}
4538
}
4639

40+
componentWillUnmount() {
41+
const { pdf } = this.state;
42+
pdf.destroy();
43+
}
44+
4745
onGetPdfRaw(pdfRaw) {
4846
const { onContentAvailable, onBinaryContentAvailable, binaryToBase64 } = this.props;
4947
if (typeof onBinaryContentAvailable === 'function') {
@@ -96,7 +94,7 @@ class Pdf extends React.Component {
9694
reader.readAsArrayBuffer(props.file);
9795
} else if (props.binaryContent) {
9896
this.loadByteArray(props.binaryContent);
99-
} else if (props.content) {
97+
} else if (!!props.content) {
10098
const bytes = window.atob(props.content);
10199
const byteLength = bytes.length;
102100
const byteArray = new Uint8Array(new ArrayBuffer(byteLength));

0 commit comments

Comments
 (0)