❌ ERROR: Invariant Violation: `new NativeEventEmitter()` requires a non-null argument. - Project Setup
See original GitHub issuePrerequisites
- I am running the latest version
- I checked the documentation and found no answer
- I checked to make sure that this issue has not already been filed
- I checked all example applications mentioned in README file and they don’t work for me.
- I followed every installation step mentioned in README file.
Setup problem
I am trying to setup react-native-ble-plx to my expo app but I am getting this error:
ERROR Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
Steps to Reproduce
import React, { useState } from "react";
import {
View,
Text,
TouchableOpacity,
StyleSheet,
Button,
ImageBackground,
Image,
} from "react-native";
import { COLORS, SIZES, assets, styles1, styles2 } from "../constants";
import { Avatar } from "@rneui/themed";
import { BleManager } from "react-native-ble-plx";
import DeviceCard from "../components/DeviceCard";
const Home = ({ navigation }) => {
const manager = React.useRef();
manager.current = new BleManager({
restoreStateIdentifier: 'com.baucapstone.smartdoorlock',
restoreStateFunction: () => {},
allowDuplicate: false,
});
var devices = [];
const [isLoading, setIsLoading] = useState(false);
const scanDevices = () => {
setIsLoading(true);
manager.startDeviceScan(null, null, (error, scannedDevice) => {
if (error) {
console.warn(error);
}
if (scannedDevice && !devices.find((dev) => dev.id === scannedDevice.id)) {
console.log(scannedDevice)
devices = [
...devices,
{id: scannedDevice.id, name: scannedDevice.name},
];
}
});
setTimeout(() => {
manager.stopDeviceScan();
setIsLoading(false);
}, 5000);
};
return (
<View
style={{
flex: 1,
}}
>
<Button color="#3b5998" title="Scan bluetooth devices" onPress={scanDevices} />
{devices.map((device) => <DeviceCard device={device} />)}
<ImageBackground
source={require("../assets/images/background.png")}
resizeMode="cover"
style={{
flex: 1,
justifyContent: "center",
}}
>
<View
style={{
flex: 1,
justifyContent: "space-around",
alignItems: "center",
}}
>
<View
style={{
width: "100%",
alignItems: "flex-start",
top: -45,
left: 10,
}}
>
<Text
style={{
fontSize: SIZES.extraLarge,
fontWeight: "bold",
}}
>
Home
</Text>
</View>
<View>
<TouchableOpacity
style={{
borderWidth: 2,
borderColor: "#0782F9",
width: 200,
padding: 15,
paddingRight: 30,
borderRadius: 10,
alignItems: "center",
flexDirection: "row",
justifyContent: "space-around",
alignItems: "center",
}}
>
<Image source={require("../assets/icons/unlock.png")} />
<Text
style={{
fontSize: 18,
fontWeight: "bold",
}}
>
Lock
</Text>
</TouchableOpacity>
</View>
<View
style={{ flexDirection: "row", alignItems: "center", top: -60 }}
>
<Avatar
size="medium"
rounded
source={{ uri: "https://i.pravatar.cc/400" }}
/>
<View
style={{
padding: 10,
}}
>
<Text style={{ fontWeight: "bold" }}>
last access 7.46AM by bilgesu
</Text>
<Text style={{ fontWeight: "bold" }}>door was unlocked</Text>
</View>
</View>
</View>
</ImageBackground>
</View>
);
};
export default Home;
- Library version: latest version
- Platform: iOS.
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top Results From Across the Web
Invariant Violation: new NativeEventEmitter() requires a non ...
Go to ios folder then remove. Pods & Podfile.lock; run pod install; Rebuild project. And make sure you have followed the installation ......
Read more >Invariant Violation: `new NativeEventEmitter()` requires a non ...
Install a new app following the [RN doc](Invariant Violation: new NativeEventEmitter() requires a non-null argument.) and the instructions ...
Read more >new nativeeventemitter() requires a non-null argument expo
I am trying to setup react-native-ble-plx to my expo app but I am getting this error: ERROR Invariant Violation: `new NativeEventEmitter ...
Read more >ERROR Error: Requiring module “node_modules/react-native ...
ERROR Invariant Violation : `new NativeEventEmitter()` requires a non-null argument. ... Remember to return to your main project folder because you have ...
Read more >NativeEventEmitter() Broken After Update From RN 0.64.2 To ...
On App startup, it now crashes with RN error: Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Expo users: Upgraded @config-plugins/react-native-ble-plx to version 5.0.0, and the warning went away.
I’m also encountering the same issue using Expo.
Project seems dead, there hasn’t been any commits for 10 months. 😮