Skip to content

Opacity in Touchable opacity doesn't properly react to state change #32476

@hetanthakkar

Description

@hetanthakkar

Description

Assigning a dynamic value to opacity in TouchableOpacity like
opacity:this.state.opacity?1:0.1
the TouchableOpacity will not properly react to state change i.e. if the button is pressed twice the opacity will change

WhatsApp.Video.2021-10-26.at.9.15.25.PM.mp4

Actual behaviour: opacity changes when the button is pressed twice.
Expected behviour: opacity should change when the button is pressed in the first time

Version

0.66.1

Output of react-native info

WhatsApp Image 2021-10-26 at 10 48 48 PM

Steps to reproduce

  1. Make a state for eg: active: true.

  2. set the opacity value of TouchableOpacity as opacity:this.state.opacity?1:0.1 and change the active state value to false
    when TouchableOpacity is pressed.

3)When the active state changes from true to false the opacity value of TouchableOpacity wont change.

4)Pressing TouchableOpacity second time will change the opacity value.

Snack, code example, screenshot, or link to a repository

https://snack.expo.dev/grZqEDZkF

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionIssues where the author has responded to feedback.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions