overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-preview-detached-root.js
Timothée Alby af5543f119 Merge pull request #8224 from overleaf/ta-pdf-detach-wait-i18n
PDF Detach: Wait for i18n

GitOrigin-RevId: d1774c917ba903eab9980c90dc8b1e41eaf5e935
2022-06-01 08:03:59 +00:00

30 lines
815 B
JavaScript

import ReactDOM from 'react-dom'
import PdfPreview from './pdf-preview'
import { ContextRoot } from '../../../shared/context/root-context'
import useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
import { Shortcuts } from './shortcuts'
import PdfPreviewDetachedRootSafariWarning from './pdf-preview-detached-root-safari-warning'
function PdfPreviewDetachedRoot() {
const { isReady } = useWaitForI18n()
if (!isReady) {
return null
}
return (
<ContextRoot>
<Shortcuts>
<PdfPreviewDetachedRootSafariWarning />
<PdfPreview />
</Shortcuts>
</ContextRoot>
)
}
export default PdfPreviewDetachedRoot // for testing
const element = document.getElementById('pdf-preview-detached-root')
if (element) {
ReactDOM.render(<PdfPreviewDetachedRoot />, element)
}