react-native-device-info: Can't read property 'deviceId' of undefined
After installing and linking react-native-device-info . I get the following error on iso simulator.
Can't read property 'deviceId' of undefined
packege.json
"dependencies": {
"react": "16.0.0",
"react-native": "0.50.3",
"react-native-device-info": "^0.12.1",
"react-native-fcm": "^10.0.3",
"react-native-router-flux": "^4.0.0-beta.23",
},
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 19 (1 by maintainers)
remove libRNDeviceinfo-tvOS.a it works for me 😉
I resolved this by navigating to the ios directory of the project and running
pod install
. I guess that doesn’t get run in the linking stage for iOS? I also had to fix a couple of gradle things, but all of those functions work properly now on iOS and Android - both real and emulated devices for each system.Interesting. Yeah I was trying to get the following on an iPhone X emulator:
and I tried commenting out the various lines, but they all failed. I verified that the DeviceInfo object is initialized properly with a
console.log
as well. I’m usingimport * as DeviceInfo from 'react-native-device-info'
to import the functions.So I tried your solution (which would be pretty handy), but I’m now getting
cannot read property 'isEmulator' of undefined
for that function too! I’m going to try importing the functions directly now…That happens only in the simulator.