Skip to content

Commit

Permalink
Update opacity when disabled prop is changed
Browse files Browse the repository at this point in the history
fixes #17105

If you render

```
    <TouchableOpacity
        disabled={true}
        style={{opacity: 0.5}}
    >
        ...
    </TouchableOpacity>
```

and then

```
    <TouchableOpacity
        disabled={false}
        style={{opacity: 1}}
    >
        ...
    </TouchableOpacity>
```

The content of `TouchableOpacity` will still have opacity = 0.5 because real
opacity is controlled by animated property which should be properly updated
when `disabled` prop changes.
  • Loading branch information
maxkomarychev committed Dec 7, 2017
1 parent 9f33fe2 commit ff94f25
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ var TouchableOpacity = createReactClass({
ensurePositiveDelayProps(nextProps);
},

componentDidUpdate: function(prevProps, prevState) {
if (this.props.disabled !== prevProps.disabled) {
this._opacityInactive(250);
}
},

/**
* Animate the touchable to a new opacity.
*/
Expand Down

0 comments on commit ff94f25

Please sign in to comment.