2

Error:

deprecated-react-native-prop-types

"react-native": "0.69.1",---- this error comes only in the latest version of react-native

I am facing this issues when I installed any of this library
-react-native-snap-carousel
-react-native-fast-image

Requiring module "node_modules/react-native-snap-carousel/src/index.js", which threw an exception: Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'.

deepanshu katyal
  • 631
  • 1
  • 8
  • 18

3 Answers3

2

open files

./node_modules/react-native-snap-carousel/src/carousel/Carousel.js 
./node_modules/react-native-snap-carousel/src/Pagination/Pagination.js
./node_modules/react-native-snap-carousel/src/Pagination/PaginationDot.js
./node_modules/react-native-snap-carousel/src/ParallaxImage/ParallaxImage.js

edit

import { ... ,ViewPropTypes } from 'react-native';

to

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

it will work...

Bilal Khursheed
  • 728
  • 1
  • 5
  • 12
0

This is a mistake of the old npm packages, and if the project is alive, then the developers fix it in new versions. And maybe this error will go away when you update the package to a newer one.

I found the solution for this error install typescript package should also install type definitions which resolve the error 'deprecated-react-native-prop-types' for snap crousel library

$ npm install --save @types/react-native-snap-carousel
    
         **THIS IS WORKING PERFECT FOR ME**

I PREFER TO FOLLOW THE FIRST APPROACH

OR you can follow different approach

find ViewPropTypes import in the node modules in which library this gives error delete import this file from 'react-native' and create new import

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

and its also work good but when you install new package or npm install again you have to do this steps againn for the libraries which gives same error

deepanshu katyal
  • 631
  • 1
  • 8
  • 18
0

here is the answer install this package deprecated-react-native-prop-types and if u install a new package search for this replace the below modules. these are the changes for node_modules/react-native/index.js

diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..1bc8c9d 100644
--- a/node_modules/react-native/index.js
+++ b/node_modules/react-native/index.js
@@ -435,32 +435,16 @@ module.exports = {
   },
   // Deprecated Prop Types
   get ColorPropType(): $FlowFixMe {
-    invariant(
-      false,
-      'ColorPropType has been removed from React Native. Migrate to ' +
-        "ColorPropType exported from 'deprecated-react-native-prop-types'.",
-    );
+    return require('deprecated-react-native-prop-types').ColorPropType;
   },
   get EdgeInsetsPropType(): $FlowFixMe {
-    invariant(
-      false,
-      'EdgeInsetsPropType has been removed from React Native. Migrate to ' +
-        "EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
-    );
+    return require('deprecated-react-native-prop-types').EdgeInsetsPropType;
   },
   get PointPropType(): $FlowFixMe {
-    invariant(
-      false,
-      'PointPropType has been removed from React Native. Migrate to ' +
-        "PointPropType exported from 'deprecated-react-native-prop-types'.",
-    );
+    return require('deprecated-react-native-prop-types').PointPropType;
   },
   get ViewPropTypes(): $FlowFixMe {
-    invariant(
-      false,
-      'ViewPropTypes has been removed from React Native. Migrate to ' +
-        "ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
-    );
+    return require('deprecated-react-native-prop-types').ViewPropTypes;
   },
 };
Engr.Aftab Ufaq
  • 3,356
  • 3
  • 21
  • 47