@@ -67,11 +67,12 @@ function PDFPreviewer({
6767 const [ isPasswordInvalid , setIsPasswordInvalid ] = useState ( false ) ;
6868 const containerRef = useRef < HTMLDivElement > ( null ) ;
6969 const onPasswordCallbackRef = useRef < OnPasswordCallback | null > ( null ) ;
70+ const listRef = useRef < List > ( null ) ;
7071
7172 /**
7273 * Calculate the devicePixelRatio the page should be rendered with
7374 * Each platform has a different default devicePixelRatio and different canvas limits, we need to verify that
74- * with the default devicePixelRatio it will be able to diplay the pdf correctly, if not we must change the devicePixelRatio.
75+ * with the default devicePixelRatio it will be able to display the pdf correctly, if not we must change the devicePixelRatio.
7576 * @param {Number } width of the page
7677 * @param {Number } height of the page
7778 * @returns {Number } devicePixelRatio for this page on this platform
@@ -206,6 +207,15 @@ function PDFPreviewer({
206207 ) ;
207208 } , [ isPasswordInvalid , attemptPDFLoad , setIsPasswordInvalid , renderPasswordForm ] ) ;
208209
210+ /**
211+ * Reset List style cache when dimensions change
212+ */
213+ useLayoutEffect ( ( ) => {
214+ if ( containerWidth > 0 && containerHeight > 0 ) {
215+ listRef . current ?. resetAfterIndex ( 0 ) ;
216+ }
217+ } , [ containerWidth , containerHeight ] ) ;
218+
209219 useLayoutEffect ( ( ) => {
210220 if ( ! containerRef . current ) {
211221 return undefined ;
@@ -240,6 +250,7 @@ function PDFPreviewer({
240250 >
241251 { pageViewports . length > 0 && (
242252 < List
253+ ref = { listRef }
243254 style = { { ...styles . list , ...contentContainerStyle } }
244255 outerRef = { setListAttributes }
245256 width = { isSmallScreen ? pageWidth : containerWidth }
0 commit comments