From dcf45f73b9008d5d1a84a9577a51c1a8dc0f073e Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Thu, 15 May 2025 13:34:53 -0700 Subject: [PATCH] Make use of ref-as-prop support in TouchableOpacity (#51363) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51363 Make use of the React 19 feature so that we can remove the remaining `forwardRef` in react native. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D74814122 fbshipit-source-id: 88a184f84b811ad527e004edf0eb2344db8fe266 --- .../Libraries/Components/Touchable/TouchableOpacity.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js index c965c5ad02f..8bba7ab1467 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js @@ -379,9 +379,13 @@ class TouchableOpacity extends React.Component< const Touchable: component( ref?: React.RefSetter>, ...props: TouchableOpacityProps -) = React.forwardRef((props, ref) => ( - -)); +) = ({ + ref, + ...props +}: { + ref?: React.RefSetter>, + ...TouchableOpacityProps, +}) => ; Touchable.displayName = 'TouchableOpacity';