Skip to content

Commit

Permalink
Remove propTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Apr 26, 2024
1 parent 0e02a4d commit 863e441
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 289 deletions.
1 change: 0 additions & 1 deletion packages/react-pdf/package.json
Expand Up @@ -61,7 +61,6 @@
"make-event-props": "^1.6.0",
"merge-refs": "^1.2.1",
"pdfjs-dist": "3.11.174",
"prop-types": "^15.6.2",
"tiny-invariant": "^1.0.0",
"warning": "^4.0.0"
},
Expand Down
1 change: 0 additions & 1 deletion packages/react-pdf/src/Document.spec.tsx
Expand Up @@ -18,7 +18,6 @@ const pdfFile2 = loadPDF('./../../__mocks__/_pdf2.pdf');

const OK = Symbol('OK');

// eslint-disable-next-line react/prop-types
function ChildInternal({
renderMode,
rotate,
Expand Down
58 changes: 0 additions & 58 deletions packages/react-pdf/src/Document.tsx
@@ -1,7 +1,6 @@
'use client';

import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
import PropTypes from 'prop-types';
import makeEventProps from 'make-event-props';
import makeCancellable from 'make-cancellable-promise';
import clsx from 'clsx';
Expand Down Expand Up @@ -29,7 +28,6 @@ import {
} from './shared/utils.js';

import useResolver from './shared/hooks/useResolver.js';
import { eventProps, isClassName, isFile, isRef } from './shared/propTypes.js';

import type { PDFDocumentProxy } from 'pdfjs-dist';
import type { EventProps } from 'make-event-props';
Expand Down Expand Up @@ -635,60 +633,4 @@ const Document = forwardRef(function Document(
);
});

const isFunctionOrNode = PropTypes.oneOfType([PropTypes.func, PropTypes.node]);

Document.propTypes = {
...eventProps,
children: PropTypes.node,
className: isClassName,
error: isFunctionOrNode,
externalLinkRel: PropTypes.string,
externalLinkTarget: PropTypes.oneOf(['_self', '_blank', '_parent', '_top'] as const),
file: isFile,
imageResourcesPath: PropTypes.string,
inputRef: isRef,
loading: isFunctionOrNode,
noData: isFunctionOrNode,
onItemClick: PropTypes.func,
onLoadError: PropTypes.func,
onLoadProgress: PropTypes.func,
onLoadSuccess: PropTypes.func,
onPassword: PropTypes.func,
onSourceError: PropTypes.func,
onSourceSuccess: PropTypes.func,
options: PropTypes.shape({
canvasFactory: PropTypes.any,
canvasMaxAreaInBytes: PropTypes.number,
cMapPacked: PropTypes.bool,
CMapReaderFactory: PropTypes.any,
cMapUrl: PropTypes.string,
disableAutoFetch: PropTypes.bool,
disableFontFace: PropTypes.bool,
disableRange: PropTypes.bool,
disableStream: PropTypes.bool,
docBaseUrl: PropTypes.string,
enableXfa: PropTypes.bool,
filterFactory: PropTypes.any,
fontExtraProperties: PropTypes.bool,
httpHeaders: PropTypes.object,
isEvalSupported: PropTypes.bool,
isOffscreenCanvasSupported: PropTypes.bool,
length: PropTypes.number,
maxImageSize: PropTypes.number,
ownerDocument: PropTypes.any,
password: PropTypes.string,
pdfBug: PropTypes.bool,
rangeChunkSize: PropTypes.number,
StandardFontDataFactory: PropTypes.any,
standardFontDataUrl: PropTypes.string,
stopAtErrors: PropTypes.bool,
useSystemFonts: PropTypes.bool,
useWorkerFetch: PropTypes.bool,
verbosity: PropTypes.number,
withCredentials: PropTypes.bool,
worker: PropTypes.any,
}),
rotate: PropTypes.number,
};

export default Document;
12 changes: 0 additions & 12 deletions packages/react-pdf/src/Outline.tsx
@@ -1,7 +1,6 @@
'use client';

import { useEffect, useMemo } from 'react';
import PropTypes from 'prop-types';
import makeCancellable from 'make-cancellable-promise';
import makeEventProps from 'make-event-props';
import clsx from 'clsx';
Expand All @@ -16,7 +15,6 @@ import { cancelRunningTask } from './shared/utils.js';

import useDocumentContext from './shared/hooks/useDocumentContext.js';
import useResolver from './shared/hooks/useResolver.js';
import { eventProps, isClassName, isPdf, isRef } from './shared/propTypes.js';

import type { PDFDocumentProxy } from 'pdfjs-dist';
import type { EventProps } from 'make-event-props';
Expand Down Expand Up @@ -204,14 +202,4 @@ const Outline: React.FC<OutlineProps> = function Outline(props) {
);
};

Outline.propTypes = {
...eventProps,
className: isClassName,
inputRef: isRef,
onItemClick: PropTypes.func,
onLoadError: PropTypes.func,
onLoadSuccess: PropTypes.func,
pdf: isPdf,
};

export default Outline;
48 changes: 0 additions & 48 deletions packages/react-pdf/src/Page.tsx
@@ -1,7 +1,6 @@
'use client';

import { useEffect, useMemo, useRef } from 'react';
import PropTypes from 'prop-types';
import makeCancellable from 'make-cancellable-promise';
import makeEventProps from 'make-event-props';
import clsx from 'clsx';
Expand All @@ -21,16 +20,6 @@ import { cancelRunningTask, isProvided, makePageCallback } from './shared/utils.

import useDocumentContext from './shared/hooks/useDocumentContext.js';
import useResolver from './shared/hooks/useResolver.js';
import {
eventProps,
isClassName,
isPageIndex,
isPageNumber,
isPdf,
isRef,
isRenderMode,
isRotate,
} from './shared/propTypes.js';

import type { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
import type { EventProps } from 'make-event-props';
Expand Down Expand Up @@ -657,41 +646,4 @@ const Page: React.FC<PageProps> = function Page(props) {
);
};

const isFunctionOrNode = PropTypes.oneOfType([PropTypes.func, PropTypes.node]);

Page.propTypes = {
...eventProps,
canvasBackground: PropTypes.string,
canvasRef: isRef,
children: PropTypes.node,
className: isClassName,
customRenderer: PropTypes.func,
customTextRenderer: PropTypes.func,
devicePixelRatio: PropTypes.number,
error: isFunctionOrNode,
height: PropTypes.number,
imageResourcesPath: PropTypes.string,
inputRef: isRef,
loading: isFunctionOrNode,
noData: isFunctionOrNode,
onGetTextError: PropTypes.func,
onGetTextSuccess: PropTypes.func,
onLoadError: PropTypes.func,
onLoadSuccess: PropTypes.func,
onRenderError: PropTypes.func,
onRenderSuccess: PropTypes.func,
onRenderTextLayerError: PropTypes.func,
onRenderTextLayerSuccess: PropTypes.func,
pageIndex: isPageIndex,
pageNumber: isPageNumber,
pdf: isPdf,
renderAnnotationLayer: PropTypes.bool,
renderForms: PropTypes.bool,
renderMode: isRenderMode,
renderTextLayer: PropTypes.bool,
rotate: isRotate,
scale: PropTypes.number,
width: PropTypes.number,
};

export default Page;
1 change: 1 addition & 0 deletions packages/react-pdf/src/Thumbnail.tsx
Expand Up @@ -92,6 +92,7 @@ const Thumbnail: React.FC<ThumbnailProps> = function Thumbnail(props) {
}
}

// eslint-disable-next-line react/prop-types
const { className: classNameProps, onItemClick: onItemClickProps, ...pageProps } = props;

return (
Expand Down
167 changes: 0 additions & 167 deletions packages/react-pdf/src/shared/propTypes.ts

This file was deleted.

3 changes: 1 addition & 2 deletions yarn.lock
Expand Up @@ -4402,7 +4402,7 @@ __metadata:
languageName: node
linkType: hard

"prop-types@npm:^15.6.2, prop-types@npm:^15.8.1":
"prop-types@npm:^15.8.1":
version: 15.8.1
resolution: "prop-types@npm:15.8.1"
dependencies:
Expand Down Expand Up @@ -4521,7 +4521,6 @@ __metadata:
nodemon: "npm:^3.0.0"
pdfjs-dist: "npm:3.11.174"
prettier: "npm:^3.2.0"
prop-types: "npm:^15.6.2"
react: "npm:^18.2.0"
react-dom: "npm:^18.2.0"
rimraf: "npm:^3.0.0"
Expand Down

0 comments on commit 863e441

Please sign in to comment.