I have a button next to a TextInput
that increases its counter when pressed.
<TouchableWithoutFeedback onPress={() => {this.increaseAmount(step, rowID)}}>
<View style={styles.amountPlusButtonContainer}>
<Text style={styles.amountButtonText}>+</Text>
</View>
</TouchableWithoutFeedback>
It currently increases by 1 each time I tap the button. What I want to achieve is to keep increasing the counter for as long as the user is pressing it.
I have tried to use setInterval()
but I don't know exactly when to stop it nor if it's the right approach to this problem.
I think to use setInterval
is a good solution.
Call setInterval
on onPressIn and clearInterval
on onPressOut.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With