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

Error: Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. #348

Open
YogeshBhatt opened this issue Oct 13, 2022 · 3 comments

Comments

@YogeshBhatt
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-htmlview/HTMLView.js b/node_modules/react-native-htmlview/HTMLView.js
index 43f8b7e..654699c 100644
--- a/node_modules/react-native-htmlview/HTMLView.js
+++ b/node_modules/react-native-htmlview/HTMLView.js
@@ -1,13 +1,16 @@
 import React, {PureComponent} from 'react';
 import PropTypes from 'prop-types';
 import htmlToElement from './htmlToElement';
-import {Linking, Platform, StyleSheet, View, ViewPropTypes} from 'react-native';
+import {Linking, Platform, StyleSheet, View} from 'react-native';
 
 const boldStyle = {fontWeight: 'bold'};
 const italicStyle = {fontStyle: 'italic'};
 const underlineStyle = {textDecorationLine: 'underline'};
 const strikethroughStyle = {textDecorationLine: 'line-through'};
 const codeStyle = {fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace'};
+const ViewPropTypes = typeof document !== 'undefined' || Platform.OS === 'web'
+  ? PropTypes.shape({style: PropTypes.object})
+  : require('react-native').ViewPropTypes || View.propTypes;
 
 const baseStyles = StyleSheet.create({
   b: boldStyle,

This issue body was partially generated by patch-package.

@ankitjpk
Copy link

So how can we add these change to this library!
I mean without changing files in node_modules!

@Jonnathangte68
Copy link

@YogeshBhatt I created a fork with these changes, Is this alright or is it there some other better way

@lucascaldasb
Copy link

Hi!
I solve my problem by simple installing the 'deprecated-react-native-prop-types' library and importing the ViewPropTypes from there

-import {Linking, Platform, StyleSheet, View, ViewPropTypes} from 'react-native';
+import { Linking, Platform, StyleSheet, View } from 'react-native';
+import { ViewPropTypes } from 'deprecated-react-native-prop-types'

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

No branches or pull requests

4 participants