Reputation: 838
I am using TouchableHighlight for my component. <TouchableHighlight onLongPress={onLongPressButton} underlayColor="purple">
After I press out the component (I dont know if this is the right name of the action) the underlay color disappear. I want to preserve it and to make it stay. I tried using background
color for the underlying <div>
but it is not the same boundaries as underlayColor
EDIT - there is no initial collor of the component, so it is white (or whatever the default color is). No, I dont want the color to be changed on onPress
event. Just to stay "highlighted" when I remove my finger away from the onLongPress
event
Upvotes: 0
Views: 597
Reputation: 1133
you can use onPressOut
prop function of TouchableHighlight
and set state to change the color of the button.
It is called as soon as the touch is released even before onPress. The first function argument is an event in form of PressEvent
.
Reference Link : https://reactnative.dev/docs/touchablewithoutfeedback#onpressout
Upvotes: 0