-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Invariant Violation: ViewPropTypes has been removed from React Native. #33734
Comments
Thanks for reporting this. It's tracked here also: reactwg/react-native-releases#21 (comment) |
Hi @BobDev1, is this issue still happening or can we consider the issue closed? |
same issue |
Same here after bumping up to "0.69.0"
|
Same issue here after upgrading to 0.69, there are a lot of external libraries still using ViewPropTypes. Perhaps an unpopular opinion, but maybe it's too early to deprecate ViewPropTypes completely? |
Hi, this issue can be solved using babel-plugin-module-resolver you can alias react-native module, with example like bellow
saved the code to javascript file to use in babel config, and you need to set up a proper resolver for allowlist/blocklist certain library that can result in a conflicting file.
|
Still an issue in |
I'm interested in this solution but I'm not very familiar with how to use the module resolver. Could you please provide a sample complete solution with filename/locations? Would be very helpful! Thank you.. UPDATE: I got the resolver implemented and running but it doesn't seem to be use the deprecated-react-native-prop-types. Still getting the following on app start.
UPDATE 2: I removed the last check on the filtering 'if' statement "currentFile.includes("node_modules\react-native\") === false" and it stopped complaining about prop types. Now the complaint is..
|
I'm having this issue on iOS (not Android) with library @alessiocancian/react-native-actionsheet which doen't even import prop-types but contains a TypeScript source file. I suspect many other libraries are in the same situation.
|
Hi, I use babel-plugin-module-resolver based on experience dealing with the same issue to 'overrides' certain native components inside the react-native package which not working in web implementation (react-native-web). @ajp8164 |
Thanks for the help! Would you mind explaining where that first code segment is getting saved where you sub out the missing prop types and how its getting referenced by the My understanding was saving it in Then
In babel.config.js And in the .babelrc having an
Is this correct? |
I create an example GitHub repo using the standard init project, here is the link |
@psycheangel will you be able to explain exactly what needs to be changed? Thanks! |
@ajp8164 Hi, I'm facing the exact same issue like you. have you resolved it already? |
I create a readme file in the GitHub example link |
Any suggestion how to know which dependencies were affected by this issue? |
This is a big issue for anyone that wants to upgrade react-native. It will be great if we can find a workaround, as going manually and looking for the hundreds of places in which a 3rd party package requires a correction, and patching the correction, is just not feasible. |
Same problem, just downgrade and wait for someone to fix it |
I've been using this resolver solution for a while and it works very well. No intrusion. |
Have you resolved this problem, other than patching? I tried the patch option but it returns the following: I have already done and it keeps sending the same error. I would like to use version 69.4 but I have many third party libraries that use propsType so it is not working. |
@MohammadAyazSheikh did you manage to solve it ? |
@mukti107 you can place a complete example that has worked for you, when I run your example it returns the following message. |
same issue here version 0.69.4 |
any news ? |
no 😐 |
Just wanted to share our experience regarding this issue in case it helps anyone (this probably won't help people who are stuck with old dependency versions). We were seeing this error and simply needed to update 2 of our dependencies ( |
it doesn't seems working . babel.config var path = require('path'); plugins: [
], |
@mukti107 your solution sends the following error message, you know how to fix it: _reactNative.TextInput.propTypes.style |
There should be a stack trace and/or component stack trace that points to the component/library causing the issue. If you think it's in your application, and not a library, you could grep for all usages of the deprecated prop types. If you can share a repo, I'm happy to take a look to help debug what's using the PropTypes. |
If I understand well the revolver solution only works for babel so people using hermes still have the issue. Anyone knows the equivalent of that solution on hermes ? |
This comment was marked as outdated.
This comment was marked as outdated.
Did you solve this issue |
For me I used the "temporary" solution with patch-package : #33734 (comment) The solution with the resolver only works if you use babel, but if you use hermes like me this solution will not have any effect. So the patch-package can be temporary solution will waiting for the dependencies to publish an update. |
We were using What would be the easiest fix for this? |
There is no easy fix for this. It's a problem in react-native library. |
For those who don't use hermes, you can solve the _reactNative.textInput.propTypes.style error using the method of @mukti107 and @psycheangel only that I have added a new option that has neither of the 2 forms. They must create a file in the root with the name they like in my case rn-polyfill-depricated-proptypes.js and they will place it in the index.js of the project at the top like this after this add the following to the created file ` /** const StandardModule = require('react-native'); const txtImputProx = new Proxy(StandardModule.TextInput, { Object.defineProperty(StandardModule, 'ColorPropType', { Object.defineProperty(StandardModule, 'EdgeInsetsPropType', { Object.defineProperty(StandardModule, 'PointPropType', { Object.defineProperty(StandardModule, 'ViewPropTypes', { Object.defineProperty(StandardModule, 'TextPropTypes', { Object.defineProperty(StandardModule, 'TextInputPropTypes', { Object.defineProperty(StandardModule, 'TextInput', { // Object.defineProperty(StandardModule, 'TextStylePropTypes', { // Object.defineProperty(StandardModule, 'ImagePropTypes', { // Object.defineProperty(StandardModule, 'ImageStylePropTypes', { // Object.defineProperty(StandardModule, 'ViewStylePropTypes', { // console.log("StandardModule--> ", StandardModule.ColorPropType); ` This way it will work for them and the app will run perfectly, but in my case FETCH() doesn't work for me, does anyone have an idea why fetech doesn't work in react-native 69.4 very thankful. I hope the contribution helps you. |
In my case, the app is working but the fetch only works after about 10 minutes, someone will know what's going on. |
Fixed issue for 69.4 and the fetch() issue is because it was using react-native-cli and should be removed. |
@CCB-cerivera It would be nice if that polyfill module just implemented your solution. It's much simpler than using babel or any of the other solutions, and should work everywhere. Hopefully most dependencies will have this problem fixed soon, but your code could be a useful NPM package if you're feeling ambitious. Either way, it's working well for me. Thanks! |
This comment was marked as outdated.
This comment was marked as outdated.
@ha-abdou please use the above solution it will work for you without having to patch. |
Locking this to prevent confusion as the recommended fix is getting buried. The recommended fix is [here](#33734 (comment). |
Hey all, just to re-iterate, back in 2018 we started to remove PropTypes from React Native. Last year, in 0.68 we introduced a deprecation warning which notified users that the change is coming, and in 0.69 we removed the PropTypes entirely. Because of this it is not recommended to ignore the warning as some comments above suggest (I've hidden those comments as outdated to prevent confusion). If you ignore the warning then in a future version you will hit issues like #33734 when we fully remove the deprecated code. It's also not recommend to use patch-package on the React Native file because this will only mask the issue. Recommended FixThe recommended fix is to switch from PropTypes to a type system like TypeScript. If you need to continue using PropTypes, the fix is to find the code that is using PropTypes and switch the import from: import { ViewPropTypes } from 'react-native'; to: import { ViewPropTypes } from 'deprecated-react-native-prop-types'; Sometimes, a library you depend on may be using the PropTypes. In that case, it's recommended to submit an issue or PR to the library and/or update to the latest version. In extreme cases (like the library you're using is unmaintained) you may need to fork the library, or use patch-package for that library itself to replace the types until it's fixed upstream. Improving the error reportingWe've heard feedback that it can be hard to find the source of the component that is using the deprecated types. We've shipped two fixes to address this issue. Code frames for the source of the issueFirst, we added better stack frame collapsing to internal React Native frames so that LogBox shows you where the type is being used: This fix is available in 0.70, but you may need to bump the CLI version with the instructions here. Reporting crashes in the appSecond, we found an issue where propTypes errors could crash the app without reporting any errors other than the console. This makes it really difficult to find which component or library are using propTypes because the console doesn't report the stack trace. This is being addressed by #34649, which will display the error in LogBox instead of the white screen. This will land in the next release a the latest, but as a workaround you can add: require('../ReactNative/AppRegistry'); To line SummaryThe correct fix here is to switch to Please do not patch or ignore warnings to work around this issue. If you have any trouble finding the source of the prop type usage, please file a new issue with repro steps so we can help you find the source and fix the error reporting to make it easier to find the source. |
Description
Recently updated react to 18 version, and since that I'm not able to build my app. At first I've received "TypeError: dispatcher.useSyncExternalStore is not a function." and fixed by updating react-native to "0.69.0-rc.0" version. But now having these errors:
Version
0.69.0-rc.0
Output of
npx react-native info
OS: Linux 5.13 Ubuntu 20.04.4 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Memory: 1.75 GB / 15.50 GB
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
Yarn: Not Found
npm: 8.7.0 - ~/.nvm/versions/node/v12.14.1/bin/npm
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: ^0.69.0-rc.0 => 0.69.0-rc.0
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
react-native run-android
Snack, code example, screenshot, or link to a repository
No response
The text was updated successfully, but these errors were encountered: