ViewPropTypes will be removed from React Native. Migrate to ViewPropTypes exported from ‘deprecated-react-native-prop-types

Solution:

  1. Install patch-package into your project, as per the instructions.

  2. Install deprecated-react-native-prop-types by running npm install deprecated-react-native-prop-types or yarn add deprecated-react-native-prop-types.

  3. The invariant seems to be enforced in node_modules/react-native/index.js, starting at line 436:

image

here is my patch file react-native+0.69.3.patch

diff --git a/node_modules/react-native/ReactCommon/React-bridging.podspec b/node_modules/react-native/ReactCommon/React-bridging.podspec
index 5255c13..52a8eb0 100644
--- a/node_modules/react-native/ReactCommon/React-bridging.podspec
+++ b/node_modules/react-native/ReactCommon/React-bridging.podspec
@@ -30,7 +30,7 @@ Pod::Spec.new do |s|
   s.source                 = source
   s.source_files           = "react/bridging/**/*.{cpp,h}"
   s.exclude_files          = "react/bridging/tests"
-  s.header_dir             = "react/bridging"
+  s.header_dir             = "."
   s.header_mappings_dir    = "."
   s.compiler_flags         = folly_compiler_flags
   s.pod_target_xcconfig    = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\"",
diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..349b4dd 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
   },
 };

So, change these lines to return the corresponding Prop Types from deprecated-react-native-prop-types instead:

image

  1. Save and run npx patch-package react-native to save the patch.

  2. Rebuild and the app should launch.

Only thing to keep in mind is that this patch will need to be reapplied with every upgrade to react-native, or until the libraries in question are updated to import from deprecated-react-native-prop-types instead.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)