Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 9babec5

Browse files
committed
Updated WebViewer
Fixed memory leak again after conversion
1 parent 302774b commit 9babec5

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@types/react-dom": "~18.0.5"
3030
},
3131
"dependencies": {
32-
"@pdftron/webviewer": "^8.10.0-20221128",
32+
"@pdftron/webviewer": "^8.11.0-20230117",
3333
"classnames": "^2.2.6",
3434
"lodash": "^4.17.21"
3535
}

src/components/PDFViewer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface InputProps {
3535
}
3636

3737
export interface ViewerState {
38+
wvInstance?: WebViewerInstance;
3839
isDocumentLoaded: boolean;
3940
currentFileId?: number;
4041
}
@@ -43,12 +44,11 @@ const hasAttribute = (attribute: any): boolean => attribute && attribute.status
4344

4445
class PDFViewer extends React.Component<InputProps, ViewerState> {
4546
viewerRef: React.RefObject<HTMLDivElement>;
46-
wvInstance?: WebViewerInstance;
4747
constructor(props: InputProps) {
4848
super(props);
4949
this.viewerRef = React.createRef();
50-
this.wvInstance = undefined;
5150
this.state = {
51+
wvInstance: undefined,
5252
isDocumentLoaded: false,
5353
currentFileId: undefined
5454
};
@@ -76,7 +76,7 @@ class PDFViewer extends React.Component<InputProps, ViewerState> {
7676
).then((instance: WebViewerInstance) => {
7777
const { Core, UI } = instance;
7878

79-
this.wvInstance = instance;
79+
this.setState({ wvInstance: instance });
8080

8181
UI.setLanguage(this.props.defaultLanguage);
8282

@@ -261,9 +261,9 @@ class PDFViewer extends React.Component<InputProps, ViewerState> {
261261
}
262262
componentWillUnmount(): void {
263263
// Perform clean-up of WV when unmounted
264-
if (this.wvInstance) {
264+
if (this.state.wvInstance) {
265265
// Disposing WV events
266-
this.wvInstance.UI.dispose();
266+
this.state.wvInstance.UI.dispose();
267267
}
268268
}
269269
render(): ReactNode {

0 commit comments

Comments
 (0)