Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use deprecated-react-native-prop-types #159

Merged
merged 1 commit into from
Oct 3, 2023
Merged

Conversation

apfritts
Copy link
Collaborator

@apfritts apfritts commented Apr 8, 2022

Platforms affected

All

What does this PR do?

RN 0.68 has deprecated and will eventually remove ViewPropTypes (see post). This adds the deprecated-react-native-prop-types package and uses that instead.

What testing has been done on this change?

Local testing, to ensure the deprecation warning has been removed.

@TowhidKashem
Copy link

hey @i6mi6 , can we get this merged please? your lib isn't usable with the latest react native version, it fails builds.

@vf-rich
Copy link

vf-rich commented Aug 27, 2022

+1 to this I'm completely blocked on this unfortunately

@TowhidKashem
Copy link

TowhidKashem commented Sep 1, 2022

+1 to this I'm completely blocked on this unfortunately

I ended up "resolving" the issue by applying the following patch that you can use the patch-package for. The good thing is since it's a React native patch it will work for any library with this issue not just this one:

diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..8023167 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
   },
 };

@vf-rich
Copy link

vf-rich commented Sep 6, 2022

+1 to this I'm completely blocked on this unfortunately

I ended up "resolving" the issue by applying the following patch that you can use the patch-package for. The good thing is since it's a React native patch it will work for any library with this issue not just this one:

diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..8023167 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
   },
 };

You deserve all the kudos in the world, this saved my ass thank you!

@swatisaingar
Copy link

swatisaingar commented Sep 14, 2023

` In react native version - 0.72.0 in index.js file we have same line of code you have provided above still its showing same error

this line of code

diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..8023167 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
   },
 };

@i6mi6 i6mi6 merged commit 39c5188 into i6mi6:master Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants