Skip to content

Commit

Permalink
Opacity in TouchableOpacity properly react to state change (#32956)
Browse files Browse the repository at this point in the history
Summary:
This PR fixes the opacity bug where it fails to properly react to state change. This PR resolves the issue detailed in #32476

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - Fixed opacity value in TouchableOpacity

Pull Request resolved: #32956

Test Plan: The code I added in componentDidUpdate does solve the issue and passes all the test cases

Reviewed By: ryancat

Differential Revision: D33766718

Pulled By: cortinico

fbshipit-source-id: 951bedf22619fc12e66156d0a6074cd8adf1d3eb
  • Loading branch information
hetanthakkar authored and facebook-github-bot committed Feb 7, 2022
1 parent 113f825 commit 3eddc9a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ class TouchableOpacity extends React.Component<Props, State> {

componentDidUpdate(prevProps: Props, prevState: State) {
this.state.pressability.configure(this._createPressabilityConfig());
if (this.props.disabled !== prevProps.disabled) {
if (
this.props.disabled !== prevProps.disabled ||
(flattenStyle(prevProps.style)?.opacity !==
flattenStyle(this.props.style)?.opacity) !==
undefined
) {
this._opacityInactive(250);
}
}
Expand Down

0 comments on commit 3eddc9a

Please sign in to comment.