I have recently upgraded to RN: 0.45.1, react-native-device-info: 0.15.1, and whenever I try to query for api level the app crashes with an error.
| | |
| ----------- | --- |
| Version | 0.15.1 |
| Affected OS | Android |
| OS Version | 8.0.0 |
Getting this error in sentry:
undefined is not an object (evaluating 'reactNativeDeviceInfo.DeviceInfo.getAPILevel')
This was working in previous version of RN 44.0 and react-native-device-info: 0.13.0
getAPILevel should give the api level
Hi @sahil290791, it seems like you forgot to link the library.
Can you try react-native link react-native-device-info?
I have linked the library and checked the manual linking steps also. Tried unlinking and linking it again.
This is obviously a linking problem as reactNativeDeviceInfo.DeviceInfo seems to be undefined.
Thanks @machour , sorry I noticed that as it was working in other components of my app, in one particular component i was importing it in an incorrect way:
// incorrect way
import { DeviceInfo } from 'react-native-device-info'`;
// correct way
import DeviceInfo from 'react-native-device-info';
No problems, thank you for reporting back!
Most helpful comment
Thanks @machour , sorry I noticed that as it was working in other components of my app, in one particular component i was importing it in an incorrect way: