react-native-device-info: Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
Summary
I have tried just about everything and still getting the error:
Invariant Violation: new NativeEventEmitter() requires a non-null argument.
See screenshot below.
| Version | 10.4.0 |
| Affected OS | iOS |
| OS Version | 15.4 |
Current behavior

Bare workflow React Native Using Storybook Cleared all pods, node_modules, and lock files. Watchman ran, DerivedData cleared.
I’m trying to use DeviceInfo.getFontScale() and get that error. I cannot seem to figure out what’s going on.
Here’s the simple task I have:
const [deviceInfo, setDeviceInfo] = useState<number>();
useEffect(() => {
try {
DeviceInfo.getFontScale().then((fontScale) => {
setDeviceInfo(fontScale);
});
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
}
}, []);
// eslint-disable-next-line no-console
console.log(deviceInfo);
As soon as I comment out the method usage, index loads like normal.
Expected behavior
Being able to use the methods in this package without errors
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
Terminate metro, close the simulator, pod install and run the app again (npm run ios). Worked for me
I needed to delete the app and reinstall it using
react-native run-ioscd /xxx/ios rm -rf Pods rm -rf build pod install
I solved this just running
npx pod-installI solved this by adding
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'to myPodfileafter seeing thatNativeEventEmitteris being called correctly in the lib.