11import pdfWorkerSource from 'pdfjs-dist/build/pdf.worker.min.mjs' ;
2- import React , { useCallback , useLayoutEffect , useRef , useState } from 'react' ;
2+ import React , { useCallback , useLayoutEffect , useRef , useState , memo } from 'react' ;
33import type { CSSProperties , ReactNode , JSX } from 'react' ;
44import { times } from 'lodash' ;
55import { VariableSizeList as List } from 'react-window' ;
@@ -11,7 +11,7 @@ import type {PDFDocument, PageViewport, RotationDegrees} from './types.js';
1111import { pdfPreviewerStyles as styles } from './styles.js' ;
1212import PDFPasswordForm , { type PDFPasswordFormProps } from './PDFPasswordForm.js' ;
1313import PageRenderer from './PageRenderer.js' ;
14- import { PAGE_BORDER , LARGE_SCREEN_SIDE_SPACING , DEFAULT_DOCUMENT_OPTIONS , DEFAULT_EXTERNAL_LINK_TARGET , PDF_PASSWORD_FORM_RESPONSES , ROTATION } from './constants.js' ;
14+ import { PAGE_BORDER , LARGE_SCREEN_SIDE_SPACING , DEFAULT_DOCUMENT_OPTIONS , DEFAULT_EXTERNAL_LINK_TARGET , PDF_PASSWORD_FORM_RESPONSES } from './constants.js' ;
1515import { setListAttributes } from './helpers.js' ;
1616
1717type Props = {
@@ -53,7 +53,7 @@ function PDFPreviewer({
5353 contentContainerStyle,
5454 shouldShowErrorComponent = true ,
5555 onLoadError,
56- rotation = ROTATION . DEG_0 ,
56+ rotation = 0 ,
5757} : Props ) : JSX . Element {
5858 const [ pageViewports , setPageViewports ] = useState < PageViewport [ ] > ( [ ] ) ;
5959 const [ numPages , setNumPages ] = useState ( 0 ) ;
@@ -119,7 +119,7 @@ function PDFPreviewer({
119119 const { width : originalWidth , height : originalHeight } = pageViewports [ pageIndex ] ;
120120
121121 // Swap dimensions when rotated 90 or 270 degrees
122- const isRotated90or270 = rotation === ROTATION . DEG_90 || rotation === ROTATION . DEG_270 ;
122+ const isRotated90or270 = rotation === 90 || rotation === 270 ;
123123 const pageViewportWidth = isRotated90or270 ? originalHeight : originalWidth ;
124124 const pageViewportHeight = isRotated90or270 ? originalWidth : originalHeight ;
125125
@@ -289,4 +289,4 @@ function PDFPreviewer({
289289
290290PDFPreviewer . displayName = 'PDFPreviewer' ;
291291
292- export default PDFPreviewer ;
292+ export default memo ( PDFPreviewer ) ;
0 commit comments