Skip to content

Commit 3eddc9a

Browse files
hetanthakkarfacebook-github-bot
authored andcommitted
Opacity in TouchableOpacity properly react to state change (#32956)
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
1 parent 113f825 commit 3eddc9a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Libraries/Components/Touchable/TouchableOpacity.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,12 @@ class TouchableOpacity extends React.Component<Props, State> {
260260

261261
componentDidUpdate(prevProps: Props, prevState: State) {
262262
this.state.pressability.configure(this._createPressabilityConfig());
263-
if (this.props.disabled !== prevProps.disabled) {
263+
if (
264+
this.props.disabled !== prevProps.disabled ||
265+
(flattenStyle(prevProps.style)?.opacity !==
266+
flattenStyle(this.props.style)?.opacity) !==
267+
undefined
268+
) {
264269
this._opacityInactive(250);
265270
}
266271
}

0 commit comments

Comments
 (0)