My code:
componentDidMount() {
this.getEmail;
console.log("checkpoint")
}
getEmail = () => {
var email="something";
this.setState({
email: email,
});
console.log(this.state.email)
}
render() {
return (
<View>
<Text style={styles.text} onPress={this.getEmail}>email :{this.state.email}</Text>
</View>
);
}
Console.logs :
//nothing happened?
checkpoint
(onPress Text into JSX)
this.state.email
something
So my function works well but ComponentDidMount doesn't execute getEmail, but if i press "email :" this load my state and all is fine.
I would like that ComponentDidMount execute my function