Abhishek Sharma
Abhishek Sharma

Reputation: 75

setOpacityTo() with <TouchableOpacity> in react-native

How to use the method setOpacityTo() with <TouchableOpacity> in react-native ?

setOpacityTo((value: number), (duration: number));

https://facebook.github.io/react-native/docs/0.42/touchableopacity.html

Upvotes: 4

Views: 5097

Answers (1)

sebastianf182
sebastianf182

Reputation: 9978

<TouchableHighlight ref="touch" onPress={this.onPress}/>

this.refs.touch.setOpacityTo(50);

I guess that should work.

When you use the ref prop in any React component, you are basically adding that instance into a global registry of components where they store a reference that you can access later.

The way you access that instance later is by using the this.refs.

That way, you can then call the component method that will set the opacity.

Upvotes: 1

Related Questions