Skip to content

Commit

Permalink
Unmounting the PDFViewer now destroys the connections layer
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimon committed Nov 16, 2022
1 parent e3e49b8 commit 769b01a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pdf/PDFViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ const PDFViewer = props => {
// Load PDF on mount
useEffect(() => {
// Init after DOM load
setConnections(new Connections([], {
const conn = new Connections([], {
showLabels: true,
vocabulary: props.config.relationVocabulary
}));
});

setConnections(conn);

PDFJS.getDocument(props.url).promise
.then(
pdf => setPdf(pdf),
error => console.error(error)
);

// Destroy connections layer on unmount
return () => conn.destroy();
}, []);

useEffect(() => {
Expand Down

0 comments on commit 769b01a

Please sign in to comment.