From 153a88c96cb016116839c5066d05fb2b56b62603 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Fri, 26 Apr 2024 14:11:45 +0200 Subject: [PATCH] Explicitly provide undefined to useRef() --- packages/react-pdf/src/Document.tsx | 4 ++-- packages/react-pdf/src/Page/TextLayer.tsx | 2 +- packages/react-pdf/src/shared/hooks/useCachedValue.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-pdf/src/Document.tsx b/packages/react-pdf/src/Document.tsx index 107294fbc..dd723790c 100644 --- a/packages/react-pdf/src/Document.tsx +++ b/packages/react-pdf/src/Document.tsx @@ -271,8 +271,8 @@ const Document = forwardRef(function Document( const pages = useRef([]); - const prevFile = useRef(); - const prevOptions = useRef(); + const prevFile = useRef(undefined); + const prevOptions = useRef(undefined); useEffect(() => { if (file && file !== prevFile.current && isParameterObject(file)) { diff --git a/packages/react-pdf/src/Page/TextLayer.tsx b/packages/react-pdf/src/Page/TextLayer.tsx index d05ba7cf0..36be738a3 100644 --- a/packages/react-pdf/src/Page/TextLayer.tsx +++ b/packages/react-pdf/src/Page/TextLayer.tsx @@ -40,7 +40,7 @@ export default function TextLayer() { const [textContentState, textContentDispatch] = useResolver(); const { value: textContent, error: textContentError } = textContentState; const layerElement = useRef(null); - const endElement = useRef(); + const endElement = useRef(undefined); warning( parseInt( diff --git a/packages/react-pdf/src/shared/hooks/useCachedValue.ts b/packages/react-pdf/src/shared/hooks/useCachedValue.ts index dba3b3bbc..49aa580ae 100644 --- a/packages/react-pdf/src/shared/hooks/useCachedValue.ts +++ b/packages/react-pdf/src/shared/hooks/useCachedValue.ts @@ -5,7 +5,7 @@ import { useRef } from 'react'; import { isDefined } from '../utils.js'; export default function useCachedValue(getter: () => T): () => T { - const ref = useRef(); + const ref = useRef(undefined); const currentValue = ref.current;