In the below code, I want to call both methods on the onPress
event, but I'm facing some issues. How can I call two methods on an onpress event?
One method for start chatting and the second for changing images on the onpress event.
chatStart = () => {
var { msg } = this.state;
var { o_code } = this.state;
var ucod = o_code;
//console.log(o_code);
var { session } = this.state;
//console.log(session);
var { ocod } = this.state;
//console.log(ocod);
var { Name } = this.state;
var user_name = Name;
var request = new XMLHttpRequest();
request.onreadystatechange = e => {
if (request.readyState !== 4) {
return;
}
if (request.status === 200) {
console.log("success", request.responseText);
} else {
console.warn("error");
}
};
// var msg = "good things take some time";
console.log(user_name);
request.open(
"POST",
"http://www.aonde.biz/mobile/getChat.php?ocod=" +
ocod +
"&ucod=" +
ucod +
"&session=" +
session,
true
);
request.setRequestHeader(
"Content-type",
"application/x-www-form-urlencoded"
);
request.send("message=" + msg + "&name=" + user_name + "&ocod=" + ocod);
};
changeImage = () => {
console.log("state changed!");
this.setState({
uri: require("./35-reject-red.png")
});
};
<View>
<TouchableOpacity activeOpacity={0.5} onPress={this.changeImage}>
<Image source={this.state.uri} />
</TouchableOpacity>
</View>