discussions-and-proposals icon indicating copy to clipboard operation
discussions-and-proposals copied to clipboard

activeOpacity prop in the new Pressable component

Open yogesch opened this issue 4 years ago • 1 comments

Introduction

Missing the activeOpacity prop in the new Pressable component

Details

In TouchableOpacity, it is possible to set the value of the activeOpacity prop to dim the button after it was pressed.

When the button stays dimmed while the action was being processed/loaded/etc. the user had feedback that their touch was registered and knew to not press repeatedly.

Is there anything similar in the new Pressable component? Or any way to easily achieve the same effect?

(It is of course possible to use a new state variable to disable the button, but that can involve creating actions, etc. to handle it properly)

Discussion points

Is there an easy way to achieve the same result in Pressable?

Is this worth adding to feature requests?

yogesch avatar May 15 '21 07:05 yogesch

I think it' no worth of doing that. You can easily achieve the same opacity effect by set its opacity to some value lower than 1.0 inside the onPressIn callback and reset it to 1.0 inside the onPressOut callback . So you can create a hoc Pressable Component with this opacity effect . By the way , why don't you just use TouchableOpacity instead ?

JasonCareter avatar Jan 30 '22 09:01 JasonCareter