overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-viewer.js
Jakob Ackermann 64184a7f56 Merge pull request #8730 from overleaf/jpa-refactor-pdf-caching
[web] refactor pdf caching

GitOrigin-RevId: af6b871fad652f757d8c465085b33a79b955cd6b
2022-07-07 08:03:28 +00:00

25 lines
600 B
JavaScript

import { lazy, memo } from 'react'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
const PdfJsViewer = lazy(() =>
import(/* webpackChunkName: "pdf-js-viewer" */ './pdf-js-viewer')
)
function PdfViewer() {
const { pdfUrl, pdfFile, pdfViewer } = useCompileContext()
if (!pdfUrl) {
return null
}
switch (pdfViewer) {
case 'native':
return <iframe title="PDF Preview" src={pdfUrl} />
case 'pdfjs':
default:
return <PdfJsViewer url={pdfUrl} pdfFile={pdfFile} />
}
}
export default memo(PdfViewer)