125
rated 0 times
[
129]
[
4]
/ answers: 1 / hits: 47063
/ 7 Years ago, fri, august 25, 2017, 12:00:00
I'm trying to bind the function handleClick
to my button onPress
. But it's not working. When I refresh the page, I get the alert without clicking on the button and after I close the alert and click on the button, nothing happens.
My Code is:
class ActionTest extends Component {
constructor(props) {
super(props);
this.state = {
thename: 'somename'
};
}
handleClick(){
alert('Button clicked!');
}
render(){
return(
<View>
<Button
onPress={this.handleClick()}
title=Click ME
color=blue
/>
</View>
);
}
}
I'm also getting the warning :
What am I doing wrong?
More From » reactjs