Possible Unhandled Promise Rejection
Closed this issue · 6 comments
Possible Unhandled Promise Rejection (id: 0):
null is not an object (evaluating 'matches')
please provide more information
Possible Unhandled Promise Rejection (id: 0):
null is not an object (evaluating 'matches’)
I write index.ios.js
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View
} from 'react-native';
import mqtt from 'react-native-mqtt';
class AwesomeProject extends Component {
componentDidMount(){
/* create mqtt client */
mqtt.createClient({
uri: 'mqtt://test.mosquitto.org:1883
',
clientId: 'your_client_id'
}).then(function(client) {
client.on('closed', function() {
console.log('mqtt.event.closed');
});
client.on('error', function(msg) {
console.log('mqtt.event.error', msg);
});
client.on('message', function(msg) {
console.log('mqtt.event.message', msg);
});
client.on('connect', function() {
console.log('connected');
client.subscribe('/data', 0);
client.publish('/data', "test", 0, false);
});
client.connect();
});
}
render() {
console.log("demo");
return (
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
The issue isn't with this package, it's the lack of a ‘catch‘ after the ‘then‘ in the code. If the promise is rejected, there is nothing to handle it.
I debug log react_native_mqtt index.js like this
console.log(options);
let clientRef = await Mqtt.createClient(options); // this line not any return
console.log("mqtt ref");
console.log(clientRef);
var client = new MqttClient(options, clientRef);
I try Mostly automatic install fail
But try Manual install is ok
thank you !!!
yep, I've removed automatic install, not work for me too