diff --git a/test/Test.tsx b/test/Test.tsx index a83b1ffc2..10af3c4dd 100644 --- a/test/Test.tsx +++ b/test/Test.tsx @@ -114,12 +114,23 @@ export default function Test() { [], ); + const onPageClick = useCallback( + (event: React.MouseEvent, page: PDFPageProxy | false | undefined) => + console.log('Clicked a page', { event, page }), + [], + ); + const onItemClick = useCallback((args: { pageNumber: number }) => { console.log('Clicked an item', args); const { pageNumber: nextPageNumber } = args; setPageNumber(nextPageNumber); }, []); + const customTextRenderer = useCallback( + ({ str }: { str: string }) => str.replace(/ipsum/g, (value) => `${value}`), + [], + ); + useEffect(() => { (async () => { const nextFileForProps = await (async () => { @@ -197,29 +208,6 @@ export default function Test() { const nextPage = useCallback(() => changePage(1), [changePage]); - function getPageProps() { - return { - canvasBackground, - className: 'custom-classname-page', - devicePixelRatio, - height: pageHeight, - onClick: (event: React.MouseEvent, page: PDFPageProxy | false | undefined) => - console.log('Clicked a page', { event, page }), - onRenderSuccess: onPageRenderSuccess, - renderAnnotationLayer, - renderForms, - renderMode, - renderTextLayer, - scale: pageScale, - width: pageWidth, - customTextRenderer: useCustomTextRenderer - ? ({ str }: { str: string }) => str.replace(/ipsum/g, (value) => `${value}`) - : undefined, - }; - } - - const pageProps = getPageProps(); - const documentProps = { externalLinkTarget, file: fileForProps, @@ -227,6 +215,22 @@ export default function Test() { rotate, }; + const pageProps = { + canvasBackground, + className: 'custom-classname-page', + customTextRenderer: useCustomTextRenderer ? customTextRenderer : undefined, + devicePixelRatio, + height: pageHeight, + onClick: onPageClick, + onRenderSuccess: onPageRenderSuccess, + renderAnnotationLayer, + renderForms, + renderMode, + renderTextLayer, + scale: pageScale, + width: pageWidth, + }; + return (