Cannot assign to read only property 'product' of object '#<WorkerNavigator>' initializeCore.js line 176
See original GitHub issueDescription
I’ve updated my app from react-native 0.34 to 0.37. Then when launching the app I encounter:
Cannot assign to read only property 'product' of object '#<WorkerNavigator>' initializeCore.js line 176
Now I realize that nearly no-one is going to be able to reproduce this as it is most probably a clash with one of the modules I use. Here is my package.json:
"dependencies": {
"lodash": "^4.16.6",
"moment": "^2.15.1",
"ramda": "^0.22.1",
"react": "^15.3.2",
"react-native": "^0.37.0",
"react-native-accordion": "^1.0.1",
"react-native-button": "^1.7.0",
"react-native-invertible-scroll-view": "^1.0.0",
"react-native-maps": "^0.11.0",
"react-native-modal-picker": "0.0.16",
"react-native-pullable-view": "^1.0.2",
"react-native-router-flux": "^3.37.0",
"react-native-theme-picker": "^1.0.0",
"react-native-vector-icons": "^3.0.0",
"react-redux": "^4.4.5",
"redux": "^3.6.0",
"redux-persist": "^4.0.0-alpha5",
"redux-thunk": "^2.1.0",
"tcomb-form-native": "^0.6.1",
"uuid": "^2.0.3"
},
"devDependencies": {
"babel-preset-react-native": "^1.9.0",
"babel-register": "^6.14.0",
"remote-redux-devtools": "^0.5.3",
"remote-redux-devtools-on-debugger": "^0.6.3",
"tap-spec": "^4.1.1",
"tape": "^4.6.0"
}
But I think that we have a bug in the code and here is why. I did launch a new project with
react-native init awesomeApp
The awesomeApp launched without error, unlike the app that I updated. However if you do
console.log(global.navigator)
in the render function of that dummy app I see that the product property hasn’t changed to ReactNative. For me it stays “gecko”.
I downgraded my app to 0.36.0 and it’s not crashing. The new code in intializeCore has been pushed with this commit: https://github.com/facebook/react-native/commit/606fc1148709357c3da9fb5bc45abaa251205378
if I change navigator.product = 'ReactNative';
to Object.defineProperty(navigator, 'product', {value: 'ReactNative'});
(as it was before)
then my app doesn’t crash on 0.37 and the output of console.log(global.navigator) is product = ‘ReactNative’ both in my app and in the dummy app.
Reproduction
- Clone this repository:
https://github.com/compojoom/bugreactnative
launch the app as usual -
npm install
and then launch it with xdebug.
Enable remote debugging and look at the console output - it should say “Gecko” instead of “ReactNative”
If you change the code in node_modules/react-native/Libraries/Core/InitializeCore.js on line 176 to:
Object.defineProperty(navigator, 'product', {value: 'ReactNative'});
then the output in the console should read “ReactNative”
Additional Information
-
React Native version: 0.37
-
Platform: iOS (possible on android as well)
-
Operating System: MacOS
-
works as expected with react native version: 0.36
If you also consider this a bug I would be happy to make a pull request.
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (14 by maintainers)
Top GitHub Comments
We don’t want to return Gecko probably. Something like this seems like what we want:
Ok, I thought about the same. I’ll do a PR tomorrow.