diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index c8392ea6e461..ac0583438bc1 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js @@ -140,7 +140,7 @@ export interface ScrollViewImperativeMethods { +getScrollableNode: () => ?number; +getInnerViewNode: () => ?number; +getInnerViewRef: () => InnerViewInstance | null; - +getNativeScrollRef: () => HostInstance | null; + +getNativeScrollRef: () => PublicScrollViewInstance | null; +scrollTo: ( options?: ScrollViewScrollToOptions | number, deprecatedX?: number, @@ -873,6 +873,9 @@ class ScrollView extends React.Component { getNativeScrollRef: ScrollViewImperativeMethods['getNativeScrollRef'] = () => { + // Object.assign in _scrollView's mutator augments nativeInstance in place, + // so it is already a PublicScrollViewInstance at runtime. + // $FlowFixMe[incompatible-type] return this._scrollView.nativeInstance; }; diff --git a/packages/react-native/Libraries/Lists/FlatList.js b/packages/react-native/Libraries/Lists/FlatList.js index e908863fb945..3feea7d892d5 100644 --- a/packages/react-native/Libraries/Lists/FlatList.js +++ b/packages/react-native/Libraries/Lists/FlatList.js @@ -8,7 +8,7 @@ * @format */ -import typeof ScrollViewNativeComponent from '../Components/ScrollView/ScrollViewNativeComponent'; +import type {PublicScrollViewInstance} from '../Components/ScrollView/ScrollView'; import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; import type { ListRenderItem, @@ -397,12 +397,8 @@ class FlatList extends React.PureComponent> { /** * Provides a reference to the underlying host component */ - getNativeScrollRef(): - | ?React.ElementRef - | ?React.ElementRef { + getNativeScrollRef(): ?PublicScrollViewInstance { if (this._listRef) { - /* $FlowFixMe[incompatible-return] Suppresses errors found when fixing - * TextInput typing */ return this._listRef.getScrollRef(); } } diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index 6e7dd111ae46..699a09b4b368 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<64be490fbc4d36e47ba200ba0846131f>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -90,7 +90,6 @@ declare const $$NativeDialogManagerAndroid: null | Spec | undefined declare const $$ProgressBarAndroidNativeComponent: HostComponent declare const $$ReactFabric: typeof ReactFabric_default declare const $$ScrollViewContext: typeof ScrollViewContext_default -declare const $$ScrollViewNativeComponent: typeof ScrollViewNativeComponent_default declare const $$SwitchNativeComponent: ComponentType declare const $$ViewNativeComponent: typeof ViewNativeComponent_default declare const absoluteFill: AbsoluteFillStyle @@ -400,7 +399,6 @@ declare const SafeAreaView_default: ( ) => React.ReactNode declare const ScrollView: typeof ScrollViewWrapper & ScrollViewComponentStatics declare const ScrollViewContext_default: React.Context -declare const ScrollViewNativeComponent_default: HostComponent declare const ScrollViewWrapper: ( props: ScrollViewProps & { ref?: React.Ref @@ -1016,7 +1014,6 @@ declare type $$ProgressBarAndroidNativeComponent = typeof $$ProgressBarAndroidNativeComponent declare type $$ReactFabric = typeof $$ReactFabric declare type $$ScrollViewContext = typeof $$ScrollViewContext -declare type $$ScrollViewNativeComponent = typeof $$ScrollViewNativeComponent declare type $$SwitchNativeComponent = typeof $$SwitchNativeComponent declare type $$ViewNativeComponent = typeof $$ViewNativeComponent declare type absoluteFill = typeof absoluteFill @@ -2334,9 +2331,7 @@ declare class FlatList extends React.PureComponent< componentDidUpdate(prevProps: FlatListProps): void constructor(props: FlatListProps) flashScrollIndicators(): void - getNativeScrollRef(): - | (null | React.ComponentRef | undefined) - | (null | React.ComponentRef | undefined) + getNativeScrollRef(): null | PublicScrollViewInstance | undefined getScrollableNode(): any getScrollResponder(): null | ScrollResponderType | undefined recordInteraction(): void @@ -4478,7 +4473,7 @@ declare interface ScrollViewImperativeMethods { readonly flashScrollIndicators: () => void readonly getInnerViewNode: () => number | undefined readonly getInnerViewRef: () => InnerViewInstance | null - readonly getNativeScrollRef: () => HostInstance | null + readonly getNativeScrollRef: () => null | PublicScrollViewInstance readonly getScrollableNode: () => number | undefined readonly getScrollResponder: () => ScrollResponderType readonly scrollResponderScrollNativeHandleToKeyboard: ( @@ -4505,74 +4500,6 @@ declare interface ScrollViewImperativeMethods { options?: ScrollViewScrollToOptions | undefined, ) => void } -declare type ScrollViewNativeComponent = typeof $$ScrollViewNativeComponent -declare type ScrollViewNativeProps = Readonly< - Omit & { - alwaysBounceHorizontal?: boolean - alwaysBounceVertical?: boolean - automaticallyAdjustContentInsets?: boolean - automaticallyAdjustKeyboardInsets?: boolean - automaticallyAdjustsScrollIndicatorInsets?: boolean - bounces?: boolean - bouncesZoom?: boolean - canCancelContentTouches?: boolean - centerContent?: boolean - contentInset?: EdgeInsetsProp - contentInsetAdjustmentBehavior?: - | "always" - | "automatic" - | "never" - | "scrollableAxes" - contentOffset?: PointProp - decelerationRate?: "fast" | "normal" | number - directionalLockEnabled?: boolean - disableIntervalMomentum?: boolean - endFillColor?: ColorValue - fadingEdgeLength?: - | (number | undefined) - | { - end: number - start: number - } - indicatorStyle?: "black" | "default" | "white" - isInvertedVirtualizedList?: boolean - keyboardDismissMode?: "interactive" | "none" | "on-drag" - maintainVisibleContentPosition?: { - readonly autoscrollToTopThreshold?: number - readonly minIndexForVisible: number - } - maximumZoomScale?: number - minimumZoomScale?: number - nestedScrollEnabled?: boolean - onMomentumScrollBegin?: (event: ScrollEvent) => void - onMomentumScrollEnd?: (event: ScrollEvent) => void - onResponderGrant?: (e: GestureResponderEvent) => boolean | void - onScroll?: (event: ScrollEvent) => void - onScrollBeginDrag?: (event: ScrollEvent) => void - onScrollEndDrag?: (event: ScrollEvent) => void - overScrollMode?: "always" | "auto" | "never" - pagingEnabled?: boolean - persistentScrollbar?: boolean - pinchGestureEnabled?: boolean - scrollEnabled?: boolean - scrollEventThrottle?: number - scrollIndicatorInsets?: EdgeInsetsProp - scrollPerfTag?: string - scrollsChildToFocus?: boolean - scrollsToTop?: boolean - scrollToOverflowEnabled?: boolean - sendMomentumEvents?: boolean - showsHorizontalScrollIndicator?: boolean - showsVerticalScrollIndicator?: boolean - snapToAlignment?: "center" | "end" | "start" - snapToEnd?: boolean - snapToInterval?: number - snapToOffsets?: ReadonlyArray - snapToStart?: boolean - zoomScale?: number - onScrollToTop?: (event: ScrollEvent) => void - } -> declare type ScrollViewProps = Readonly< ViewProps & ScrollViewPropsIOS & ScrollViewPropsAndroid & ScrollViewBaseProps > @@ -6067,7 +5994,7 @@ export { AlertOptions, // a0cdac0f AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // 0652b5d1 + Animated, // 5254e138 AppConfig, // ce4209a7 AppRegistry, // 5edf0524 AppState, // 12012be5 @@ -6114,8 +6041,8 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // 8c50f04a - FlatListProps, // e170f2c9 + FlatList, // 869c5a5f + FlatListProps, // 2a81c428 FocusEvent, // 62fc1eb8 FontVariant, // 7c7558bb GestureResponderEvent, // f693e9a5 @@ -6250,18 +6177,18 @@ export { SafeAreaView, // 9589fa67 ScaledSize, // 07e417c7 ScrollEvent, // 5d529218 - ScrollResponderType, // c6860ec8 + ScrollResponderType, // 114c7cc8 ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // a3918d1a - ScrollViewImperativeMethods, // 7cd8d8de - ScrollViewProps, // 429fdd65 + ScrollView, // 7180dc9b + ScrollViewImperativeMethods, // 3f95ab77 + ScrollViewProps, // 57e1167c ScrollViewPropsAndroid, // 44210553 ScrollViewPropsIOS, // b34b696c ScrollViewScrollToOptions, // 3313411e SectionBase, // b376bddc - SectionList, // 92031230 + SectionList, // c7dfd290 SectionListData, // 119baf83 - SectionListProps, // c0d0a46a + SectionListProps, // 54f880fa SectionListRenderItem, // 1fad0435 SectionListRenderItemInfo, // 745e1992 Separators, // 6a45f7e3 @@ -6326,9 +6253,9 @@ export { ViewStyle, // 00a0f8fb VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e - VirtualizedListProps, // c7e8e7d7 + VirtualizedListProps, // d414f5ca VirtualizedSectionList, // 9fd9cd61 - VirtualizedSectionListProps, // 53a7e6a4 + VirtualizedSectionListProps, // 01460821 WrapperComponentProvider, // 9cf3844c codegenNativeCommands, // 628a7c0a codegenNativeComponent, // 2baac257