Open Natetronn opened 3 years ago
I tried the above fix i.e. adding export const ViewPropTypes = { style: null };
https://github.com/necolas/react-native-web/issues/1537#issuecomment-619969653 to the bottom of node_modules/react-native-web/dist/index.js
and I'm now able to get past the above browser and terminal errors and can see the app/site but, I do get this warning in the browser console:
Warning: Failed prop type: HtmlView: prop type `style` is invalid; it must be a function, usually from the `prop-types` package, but received `object`.
in HtmlView (at App.js:74)
in App (created by ExpoRootComponent)
in ExpoRootComponent (created by RootComponent)
in RootComponent
in div (created by View)
in View (created by AppContainer)
in div (created by View)
in View (created by AppContainer)
in AppContainer index.js:1
e index.js:1
printWarning checkPropTypes.js:20
checkPropTypes checkPropTypes.js:82
React 2
render App.js:73
React 13
renderApplication renderApplication.js:23
run index.js:51
runApplication index.js:95
registerRootComponent registerRootComponent.web.tsx:14
js AppEntry.js:5
Webpack 6
I ran into the same problem and wound up having to write a patch file using patch-package
.
node_modules/react-native-htmlview/HTMLView.js
remove ViewPropTypes
from the import
statement.const ViewPropTypes = typeof document !== 'undefined' || Platform.OS === 'web'
? PropTypes.shape({style: PropTypes.object})
: require('react-native').ViewPropTypes || View.propTypes;
npx patch-package react-native-htmlview
. This will generate a patch file locally in folder named "patches".postinstall
command to your scripts like so:
"scripts": {
"postinstall": "patch-package"
}
This was what I needed to do so I could get Storybook running under my Expo example app for the project I've been working on.
I ran into the same problem and wound up having to write a patch file using
patch-package
.
- In
node_modules/react-native-htmlview/HTMLView.js
removeViewPropTypes
from theimport
statement.- Below the imports, add the following:
const ViewPropTypes = typeof document !== 'undefined' || Platform.OS === 'web' ? PropTypes.shape({style: PropTypes.object}) : require('react-native').ViewPropTypes || View.propTypes;
- Then run the following command:
npx patch-package react-native-htmlview
. This will generate a patch file locally in folder named "patches".- Now, in your package.json file, add a
postinstall
command to your scripts like so:"scripts": { "postinstall": "patch-package" }
This was what I needed to do so I could get Storybook running under my Expo example app for the project I've been working on.
Thank you much . You saved my time
change all ViewPropTypes.style
to PropTypes.style
in the source code
don't forget to import PropTypes from "prop-types";
which requires npm install prop-types
Thanks everybody for sharing your solution ideas for this. I am having these ViewPropTypes, requireNativeComponent and other similar Attempted import errors. I took over one React Native and Kotlin Springboot as a backend project. It helped in the beginning to comment out ViewPropTypes in some files, but there are so many and seems to be never ending. Not sustainable solution.
I ended up removing ViewPropTypes entirely and that got it working with the version of React Native that I'm on (0.69.6)
Simple solution here:
yarn add deprecated-react-native-prop-types
In node_modules/react-native-htmlview/HTMLView.js
remove ViewPropTypes
from the import statement.
Insert import { ViewPropTypes } from 'deprecated-react-native-prop-types'
But i hope that author will update a package so we don't need this anymore.
I tried to access the app using Expo Web and got one error in terminal and one in the browser. It seemed to work fine in Android emulator, however.
Terminal error:
Not sure if it's related but, I saw this issue as well, which also mentions HTMLView.js line 149: https://github.com/jsdf/react-native-htmlview/issues/311
And this browser error, which would seem to make sense if ViewPropTypes isn't exported any more by react-native-web. Possibly more on that here: https://github.com/necolas/react-native-web/issues/1537
And a possible solution was suggested here: https://github.com/necolas/react-native-web/issues/1537#issuecomment-619969653 (not sure that's the best way or not but, trying to help troubleshoot or at least research. Hope that helps.)
Initial browser error with no visable app/site: