Reputation: 21
I am using TouchableHighlight for making buttons, but it seems the first click event on the button does not trigger the onPress
event on the TouchableHighlight element. It works when it is clicked again.
The code looks like:
return (
<TouchableHighlight
onPress={this.props.onPress}
style={btnStyles}
underlayColor="#a30000"
activeOpacity={1}>
<Text style={styles.buttonText}>{this.props.children}</Text>
</TouchableHighlight>
);
This is the link to the button I created: https://github.com/uiheros/react-native-redux-todo-list/blob/master/app/components/shared/Button.js
Does anyone know how to fix it? or what caused the problem?
Edit: currently the problem happens to me on both ios simulator and android simulator. I have not tested in real devices yet.
Upvotes: 2
Views: 1356
Reputation: 311
I think you are using an emulator to test the app (genymotion?) same thing happened to me and I got confused but rest assured that the issue is not with you app but emulator or operation system(sometimes the first click is just to bring the emulator into focus) I am positive that if you try it on the physical device it'll work properly.
Hope I was helpful
Upvotes: 3