Files
react-native/Libraries/Components/Touchable
Gabriel Donadel Dall'Agnol 8b1f6e09c1 Fix TouchableOpacity componentDidUpdate causing an excessive number of pending callbacks (#35387)
Summary:
The commit https://github.com/facebook/react-native/commit/3eddc9abb70eb54209c68aab7dbd69e363cc7b29 included on v0.69 introduced a wrong `if` statement inside the `componentDidUpdate` function of the `TouchableOpacity` component. As this `if` statement always evaluates to `true` (`(true || false) !== undefined`) we end up making unnecessary calls to the `_opacityInactive` method every time the component props changes, e.g. every time a `<Text>` inside the TouchableOpacity changes we call this function over and over, and this has been causing some performance issues on big lists.

This PR fixes this problem by adjusting the `componentDidUpdate` function to only call  `_opacityInactive` when necessary.

Closes https://github.com/facebook/react-native/issues/34442
Closes https://github.com/facebook/react-native/issues/32476

## Changelog

[General] [Fixed] - Fix TouchableOpacity componentDidUpdate causing an excessive number of pending callbacks

Pull Request resolved: https://github.com/facebook/react-native/pull/35387

Test Plan:
1. Open the RNTester app and navigate to the `Touchable* and onPress` page
2. Test the `TouchableOpacity` component through the many sections

Reviewed By: cipolleschi

Differential Revision: D41397396

Pulled By: ryancat

fbshipit-source-id: 24863b5cbbdd2f3dd1f654b43d7031560937b888
2022-11-18 12:46:10 -08:00
..
2022-09-30 14:28:48 -07:00
2022-11-02 14:58:37 -07:00
2022-11-10 04:48:13 -08:00
2022-09-30 14:28:48 -07:00