diff --git a/packages/react-native/Libraries/Components/Button.js b/packages/react-native/Libraries/Components/Button.js index e52feb8e5209cf..6de743d1bb9fe8 100644 --- a/packages/react-native/Libraries/Components/Button.js +++ b/packages/react-native/Libraries/Components/Button.js @@ -283,10 +283,12 @@ type ButtonProps = $ReadOnly<{| const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity = Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity; -const Button: React.AbstractComponent< - ButtonProps, - React.ElementRef, -> = React.forwardRef((props: ButtonProps, ref) => { +type ButtonRef = React.ElementRef; + +const Button: component( + ref: React.RefSetter, + ...props: ButtonProps +) = React.forwardRef((props: ButtonProps, ref: React.RefSetter) => { const { accessibilityLabel, accessibilityState, diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 78185d4b309258..5fca8c7b309e16 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -1703,10 +1703,11 @@ exports[`public API should not change unintentionally Libraries/Components/Butto declare const Touchable: | typeof TouchableNativeFeedback | typeof TouchableOpacity; -declare const Button: React.AbstractComponent< - ButtonProps, - React.ElementRef, ->; +type ButtonRef = React.ElementRef; +declare const Button: component( + ref: React.RefSetter, + ...props: ButtonProps +); declare export default typeof Button; " `; diff --git a/packages/react-native/src/private/components/HScrollViewNativeComponents.js b/packages/react-native/src/private/components/HScrollViewNativeComponents.js index 9772dccb39dbad..37e754e8b7eb64 100644 --- a/packages/react-native/src/private/components/HScrollViewNativeComponents.js +++ b/packages/react-native/src/private/components/HScrollViewNativeComponents.js @@ -29,11 +29,10 @@ const HScrollViewNativeComponentForPlatform = : ScrollViewNativeComponent; // TODO: After upgrading to React 19, remove `forwardRef` from this component. -export const HScrollViewNativeComponent: React.AbstractComponent< - ScrollViewNativeProps, - TScrollViewNativeImperativeHandle, - // $FlowExpectedError[incompatible-type] - Flow cannot model imperative handles, yet. -> = forwardRef(function HScrollViewNativeComponent( +export const HScrollViewNativeComponent: component( + ref: React.RefSetter, + ...ScrollViewNativeProps +) = forwardRef(function HScrollViewNativeComponent( props: ScrollViewNativeProps, ref: ?React.RefSetter, ): React.Node { diff --git a/packages/virtualized-lists/Lists/VirtualizedSectionList.js b/packages/virtualized-lists/Lists/VirtualizedSectionList.js index 53a119899cf83f..0b531b8a7ecf08 100644 --- a/packages/virtualized-lists/Lists/VirtualizedSectionList.js +++ b/packages/virtualized-lists/Lists/VirtualizedSectionList.js @@ -601,11 +601,13 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node { /* $FlowFixMe[class-object-subtyping] added when improving typing for this * parameters */ // $FlowFixMe[method-unbinding] -module.exports = (VirtualizedSectionList: React.AbstractComponent< - React.ElementConfig, - $ReadOnly<{ - getListRef: () => ?React.ElementRef, - scrollToLocation: (params: ScrollToLocationParamsType) => void, - ... - }>, ->); +module.exports = VirtualizedSectionList as component( + ref: React.RefSetter< + $ReadOnly<{ + +getListRef: () => ?React.ElementRef, + +scrollToLocation: (params: ScrollToLocationParamsType) => void, + ... + }>, + >, + ...React.ElementConfig +);