Release builds are failing for Android on the 0.45.1 release of React Native. I've only tested this on Android, but I suspect the same is true for iOS.
Lines such as
var ReactPropTypes = require('React').PropTypes; in LayoutPropTypes.js (among several others) are causing this.
The result is a crash on startup with a js exception:
com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'ReactPropTypes.shape'), stack:
I'm aware that this is fixed on the master branch. I thought I would report this issue still, as it effectively cripples the 0.45.1 release and I need to release against master to make our app release builds work.
@andrewimm I see you fixed these lines on master, maybe you know what is going on here?
@bartolkaruza If you are using react >=15.5 you should change to prop-types package.
https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html
Same for me. If React 16 alpha is the "supported" version for React Native 0.45.1, I really don't know how can var ReactPropTypes = require('React').PropTypes; be in the code.
@tuneZola the crash is happening in the RN codebase, not our app code base. Also, the same was happening for
React.createClass calls in the RN codebase. This is on RN 0.45.1 with the recommended React version;
People will run into this issue if they upgrade to RN 45.1. Similar issues are being raised like https://github.com/facebook/react-native/issues/14590 .
Maybe it would be a good idea to cut another release that fixes this soon?
"dependencies": {
...
"react": "^16.0.0-alpha.12",
"react-native": "0.45.1",
...
},
I am experiencing the same issue after upgrading to 0.45.1
@bartolkaruza Did you read the link that I posted? This was the start of the moving of those two items. If you are used React 16.0.0, PropTypes and createClass are not in the React package anymore. You will have to change back to React 15.6.1 or some other 15.* package.
@tuneZola how we can change them if they in RN code? And how they even can be in RN code if it's supports 16+ React? for ex. - react-native\Libraries\StyleSheetLayoutPropTypes.js:14 'var ReactPropTypes = require('React').PropTypes;'
It is seperated from react..
install
npm i -S prop-types
import
import PropTypes from 'prop-types'; // ES6
var PropTypes = require('prop-types'); // ES5 with npm
more info:
https://www.npmjs.com/package/prop-types
@stoffern @tuneZola Just to help clarify this discussion. The issue is not wrong usage of the prop-types package by implementers. If you have prop-types in your package.json, it does not resolve the issue. The issue is wrong usage of prop-types from the React package in the React Native Libraries;
Basically, there is a mismatch between the React package ^16.0.0-alpha.12 and the React Native package 0.45.1. This is the default combination if you upgrade your project to 0.45.1, causing the issue. In the React Native codebase, there are references to both React.createClass and to import {PropTypes} from 'react'; Just search for it in your node_modules/react-native/Libraries if you do not feel that this could be true.
You can work around this by either downgrading the react version to pre-16, but I don't know what the potential impact is of that, I haven't tried it. Or using the non-released React Native code from master, where the references to React.createClass and PropTypes} from 'react' are already removed, at your own risk. :)
My bad, sorry. thanks for clarification @bartolkaruza
@bartolkaruza I'm not sure, but it seems like i finally got it working (though I only tried it on my emulator).
what I did was:
1) ran react-native-git-upgrade (though I already had 45.1, just in case)
2) cleaned up gradle ./gradlew clean
3) reinstalled my app npm dependencies (again, just in case)
I guess something changed in the packages, which are upgraded on the first step, or, maybe, some old libraries were somehow cached. Now it runs ok, at least on my emulator. I also did not try it with release builds, but at least it helped to continue my development. And logs still show some warnings about PropTypes (though we've set them up correctly according to migration guide), maybe because of some libraries.
@angryanatole That's great! I'm worried that something goes wrong in the minification step in release builds that cause the issue to appear, but I'm not sure. Would you mind trying a release build to confirm this? I did not have the issue in debug builds before at all.
Been going crazy with this one all day. This only was happening to me in release builds as well, but now the error is showing up in debug. At least its replicable!
Unfortunately cannot try @angryanatole's suggestion since react-native-git-upgrade is broken for me: https://github.com/facebook/react-native/issues/12237
@bartolkaruza Ok, that makes since.
@bartolkaruza no problem, just made a release build with the help of the official tutorial (we've just started, so we haven't done release builds for RN apps yet), everything seems to be fine, tested on my device and emulator. Hope this information helps!
@jjshammas if I am not mistaken, I didn't have this issue with debug builds for a couple of days after upgrading to 45.1. But it showed up yesterday, and I was really surprised. Maybe the problem was in the cached files - I don't know for sure, that's just my suggestion.
UPD: also forgot to mention, that after upgrading RN I ran react-native update
I'm a bit confused about this issue too, hope we'll get more information soon.
Have the same issue as well after upgrading to 0.45.1 via react-native-git-upgrade. Was working fine previously on 0.44.2
There's been several issues opened about this in the past week. The fix should be on master now. All that is left is to get the fix into a new 0.45 release. This is being tracked in #14712.
fix issue for me:
1) react-native-git-upgrade -> downgrade from "react-native": "0.45.1" to "0.45.0"
2) ./gradlew clean
3) react-native run-android
"react": "^16.0.0-alpha.12",
"react-native": "0.45.0",
for me running the following fixed it without additional clean:
npm install [email protected]
Guys could you please advise how you solved this issue. I changed react and react-native versions, but the problem is stacked there still. Please help to solve the issue.
Most helpful comment
for me running the following fixed it without additional clean: