Skip to content

Commit

Permalink
Explicitly provide undefined to useRef()
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Apr 26, 2024
1 parent 46b47cd commit d57f5e6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/react-pdf/src/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ const Document = forwardRef(function Document(

const pages = useRef<HTMLDivElement[]>([]);

const prevFile = useRef<File>();
const prevOptions = useRef<Options>();
const prevFile = useRef<File | undefined>(undefined);
const prevOptions = useRef<Options | undefined>(undefined);

useEffect(() => {
if (file && file !== prevFile.current && isParameterObject(file)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-pdf/src/Page/TextLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function TextLayer() {
const [textContentState, textContentDispatch] = useResolver<TextContent>();
const { value: textContent, error: textContentError } = textContentState;
const layerElement = useRef<HTMLDivElement>(null);
const endElement = useRef<HTMLElement>();
const endElement = useRef<HTMLElement | undefined>(undefined);

warning(
parseInt(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-pdf/src/shared/hooks/useCachedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRef } from 'react';
import { isDefined } from '../utils.js';

export default function useCachedValue<T>(getter: () => T): () => T {
const ref = useRef<T>();
const ref = useRef<T | undefined>(undefined);

const currentValue = ref.current;

Expand Down

0 comments on commit d57f5e6

Please sign in to comment.