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
This commit is contained in:
Sam Zhou authored and Facebook GitHub Bot committed 2025-05-15 13:34:53 -07:00
1 parent 8146c07365
commit dcf45f73b9
1 file changed
+7 -3
@@ -379,9 +379,13 @@ class TouchableOpacity extends React.Component<
const Touchable: component(
ref?: React.RefSetter<React.ElementRef<typeof Animated.View>>,
...props: TouchableOpacityProps
) = React.forwardRef((props, ref) => (
<TouchableOpacity {...props} hostRef={ref} />
));
) = ({
ref,
...props
}: {
ref?: React.RefSetter<React.ElementRef<typeof Animated.View>>,
...TouchableOpacityProps,
}) => <TouchableOpacity {...props} hostRef={ref} />;
Touchable.displayName = 'TouchableOpacity';