react-native-pdf icon indicating copy to clipboard operation
react-native-pdf copied to clipboard

ViewPropTypes is deprecated

Open billnbell opened this issue 3 years ago • 4 comments

Getting warning. ViewPropTypes is deprecated. Switch to:

import {ViewPropTypes} from 'deprecated-react-native-prop-types';

billnbell avatar Apr 07 '22 06:04 billnbell

Another solution is to remove proptypes altogether, a more forward thinking approach instead of continuing to use a deprecated feature.

tom-sherman avatar May 25 '22 11:05 tom-sherman

Yeah. I am personally facing this issue as well. Please fix this issue wonday soon. Thanks bud 🙏

dicompathakofficial avatar Jun 27 '22 14:06 dicompathakofficial

I fixed this in my project using patch-package and this patch:

react-native-pdf+6.5.0.patch
diff --git a/node_modules/react-native-pdf/DoubleTapView.js b/node_modules/react-native-pdf/DoubleTapView.js
index f0f38db..b621b8f 100644
--- a/node_modules/react-native-pdf/DoubleTapView.js
+++ b/node_modules/react-native-pdf/DoubleTapView.js
@@ -11,20 +11,10 @@ import React, {Component} from 'react';
 import {
     View,
     PanResponder,
-    ViewPropTypes,
 } from 'react-native';
-import PropTypes from 'prop-types';
 
 export default class DoubleTapView extends Component {
 
-    static propTypes = {
-        ...ViewPropTypes,
-        delay: PropTypes.number,
-        radius: PropTypes.number,
-        onSingleTap: PropTypes.func,
-        onDoubleTap: PropTypes.func,
-    };
-
     static defaultProps = {
         delay: 300,
         radius: 50,
diff --git a/node_modules/react-native-pdf/PdfPageView.js b/node_modules/react-native-pdf/PdfPageView.js
index 888fc3a..8062015 100644
--- a/node_modules/react-native-pdf/PdfPageView.js
+++ b/node_modules/react-native-pdf/PdfPageView.js
@@ -11,7 +11,6 @@
 import React, {PureComponent} from 'react';
 import PropTypes from 'prop-types';
 import {
-    ViewPropTypes,
     requireNativeComponent,
 } from 'react-native';
 
@@ -39,14 +38,6 @@ export default class PdfPageView extends PureComponent {
     }
 }
 
-PdfPageView.propTypes = {
-    ...ViewPropTypes,
-    fileNo: PropTypes.number,
-    page: PropTypes.number,
-    width: PropTypes.number,
-    height: PropTypes.number
-};
-
 PdfPageView.defaultProps = {
     style: {}
 };
diff --git a/node_modules/react-native-pdf/PdfView.js b/node_modules/react-native-pdf/PdfView.js
index cd1153d..ccf35ff 100644
--- a/node_modules/react-native-pdf/PdfView.js
+++ b/node_modules/react-native-pdf/PdfView.js
@@ -8,7 +8,7 @@
 
 'use strict';
 import React, {Component} from 'react';
-import {ScrollView, FlatList, View, StyleSheet, ViewPropTypes} from 'react-native';
+import {ScrollView, FlatList, View, StyleSheet} from 'react-native';
 
 import PropTypes from 'prop-types';
 
@@ -25,23 +25,6 @@ const VIEWABILITYCONFIG = {minimumViewTime: 500, itemVisiblePercentThreshold: 10
 
 export default class PdfView extends Component {
 
-    static propTypes = {
-        ...ViewPropTypes,
-        path: PropTypes.string,
-        password: PropTypes.string,
-        scale: PropTypes.number,
-        minScale: PropTypes.number,
-        maxScale: PropTypes.number,
-        spacing: PropTypes.number,
-        fitPolicy: PropTypes.number,
-        horizontal: PropTypes.bool,
-        page: PropTypes.number,
-        currentPage: PropTypes.number,
-        singlePage: PropTypes.bool,
-        onPageSingleTap: PropTypes.func,
-        onScaleChanged: PropTypes.func,
-    };
-
     static defaultProps = {
         path: "",
         password: "",
diff --git a/node_modules/react-native-pdf/PinchZoomView.js b/node_modules/react-native-pdf/PinchZoomView.js
index 4533480..dcdcf78 100644
--- a/node_modules/react-native-pdf/PinchZoomView.js
+++ b/node_modules/react-native-pdf/PinchZoomView.js
@@ -8,22 +8,13 @@
 
 'use strict';
 import React, {Component} from 'react';
-import PropTypes from 'prop-types';
 import {
     View,
     StyleSheet,
     PanResponder,
-    ViewPropTypes,
 } from 'react-native';
 
 export default class PinchZoomView extends Component {
-
-    static propTypes = {
-        ...ViewPropTypes,
-        scalable: PropTypes.bool,
-        onScaleChanged: PropTypes.func,
-    };
-
     static defaultProps = {
         scalable: true,
         onScaleChanged: (scale) => {
diff --git a/node_modules/react-native-pdf/index.js b/node_modules/react-native-pdf/index.js
index 10d65e4..4573e7f 100644
--- a/node_modules/react-native-pdf/index.js
+++ b/node_modules/react-native-pdf/index.js
@@ -8,12 +8,10 @@
 
 'use strict';
 import React, {Component} from 'react';
-import PropTypes from 'prop-types';
 import {
     requireNativeComponent,
     View,
     Platform,
-    ViewPropTypes,
     StyleSheet,
     Image,
     Text
@@ -26,50 +24,6 @@ import PdfView from './PdfView';
 
 export default class Pdf extends Component {
 
-    static propTypes = {
-        ...ViewPropTypes,
-        source: PropTypes.oneOfType([
-            PropTypes.shape({
-                uri: PropTypes.string,
-                cache: PropTypes.bool,
-                cacheFileName: PropTypes.string,
-                expiration: PropTypes.number,
-            }),
-            // Opaque type returned by require('./test.pdf')
-            PropTypes.number,
-        ]).isRequired,
-        page: PropTypes.number,
-        scale: PropTypes.number,
-        minScale: PropTypes.number,
-        maxScale: PropTypes.number,
-        horizontal: PropTypes.bool,
-        spacing: PropTypes.number,
-        password: PropTypes.string,
-        renderActivityIndicator: PropTypes.func,
-        enableAntialiasing: PropTypes.bool,
-        enableAnnotationRendering: PropTypes.bool,
-        enablePaging: PropTypes.bool,
-        enableRTL: PropTypes.bool,
-        fitPolicy: PropTypes.number,
-        trustAllCerts: PropTypes.bool,
-        singlePage: PropTypes.bool,
-        onLoadComplete: PropTypes.func,
-        onPageChanged: PropTypes.func,
-        onError: PropTypes.func,
-        onPageSingleTap: PropTypes.func,
-        onScaleChanged: PropTypes.func,
-        onPressLink: PropTypes.func,
-
-        // Props that are not available in the earlier react native version, added to prevent crashed on android
-        accessibilityLabel: PropTypes.string,
-        importantForAccessibility: PropTypes.string,
-        renderToHardwareTextureAndroid: PropTypes.string,
-        testID: PropTypes.string,
-        onLayout: PropTypes.bool,
-        accessibilityLiveRegion: PropTypes.string,
-        accessibilityComponentType: PropTypes.string,
-    };
-
     static defaultProps = {
         password: "",
         scale: 1,
I can also submit a PR if your're ok with removing proptypes @wonday.

bviebahn avatar Jun 28 '22 08:06 bviebahn

Maybe you want to try: https://github.com/wonday/react-native-pdf/pull/667

luutruong avatar Jul 05 '22 03:07 luutruong