Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ interface ScrollResponderMixin extends SubscribableMixin {
* down to make it meet the keyboard's top. Default is false.
*/
scrollResponderScrollNativeHandleToKeyboard(
nodeHandle: any,
nodeHandle: number | HostInstance,
additionalOffset?: number,
preventNegativeScrollOffset?: boolean,
): void;
Expand Down Expand Up @@ -836,10 +836,29 @@ export interface ScrollViewProps
StickyHeaderComponent?: React.ComponentType<any> | undefined;
}

declare class ScrollViewComponent extends React.Component<ScrollViewProps> {}
export declare const ScrollViewBase: Constructor<ScrollResponderMixin> &
typeof ScrollViewComponent;
export class ScrollView extends ScrollViewBase {
export interface ScrollViewScrollToOptions {
x?: number;
y?: number;
animated?: boolean;
}

// Public methods for ScrollView
export interface ScrollViewImperativeMethods {
/**
* Returns a reference to the underlying scroll responder, which supports
* operations like `scrollTo`. All ScrollView-like components should
* implement this method so that they can be composed while providing access
* to the underlying scroll responder's methods.
*/
readonly getScrollResponder: () => ScrollResponderType;
readonly getScrollableNode: () => number | undefined;
readonly getInnerViewNode: () => number | undefined;
readonly getInnerViewRef: () => React.ComponentRef<typeof View> | null;
/**
* Returns a reference to the underlying native scroll view, or null if the
* native instance is not mounted.
*/
readonly getNativeScrollRef: () => HostInstance | null;
/**
* Scrolls to a given x, y offset, either immediately or with a smooth animation.
* Syntax:
Expand All @@ -850,18 +869,11 @@ export class ScrollView extends ScrollViewBase {
* the function also accepts separate arguments as an alternative to the options object.
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
*/
scrollTo(
y?:
| number
| {
x?: number | undefined;
y?: number | undefined;
animated?: boolean | undefined;
},
readonly scrollTo: (
options?: ScrollViewScrollToOptions | number,
deprecatedX?: number,
deprecatedAnimated?: boolean,
): void;

) => void;
/**
* A helper function that scrolls to the end of the scrollview;
* If this is a vertical ScrollView, it scrolls to the bottom.
Expand All @@ -870,32 +882,39 @@ export class ScrollView extends ScrollViewBase {
* The options object has an animated prop, that enables the scrolling animation or not.
* The animated prop defaults to true
*/
scrollToEnd(options?: {animated?: boolean | undefined}): void;

readonly scrollToEnd: (options?: ScrollViewScrollToOptions | null) => void;
/**
* Displays the scroll indicators momentarily.
*/
flashScrollIndicators(): void;

/**
* Returns a reference to the underlying scroll responder, which supports
* operations like `scrollTo`. All ScrollView-like components should
* implement this method so that they can be composed while providing access
* to the underlying scroll responder's methods.
*/
getScrollResponder(): ScrollResponderMixin;

getScrollableNode(): any;
readonly flashScrollIndicators: () => void;
readonly scrollResponderZoomTo: (
rect: {
x: number;
y: number;
width: number;
height: number;
animated?: boolean;
},
animated?: boolean, // deprecated, put this inside the rect argument instead
) => void;
readonly scrollResponderScrollNativeHandleToKeyboard: (
nodeHandle: number | HostInstance,
additionalOffset?: number,
preventNegativeScrollOffset?: boolean,
) => void;
}

// Undocumented
getInnerViewNode(): any;
export type ScrollResponderType = ScrollViewImperativeMethods;

/**
* Returns a reference to the underlying native scroll view, or null if the
* native instance is not mounted.
*/
getNativeScrollRef: () => HostInstance | null;
export interface PublicScrollViewInstance
extends HostInstance,
ScrollViewImperativeMethods {}

declare class ScrollViewComponent extends React.Component<ScrollViewProps> {}
export declare const ScrollViewBase: Constructor<ScrollResponderMixin> &
typeof ScrollViewComponent;
export interface ScrollView extends ScrollViewImperativeMethods {}
export class ScrollView extends ScrollViewBase {
/**
* @deprecated Use scrollTo instead
*/
Expand Down
12 changes: 4 additions & 8 deletions packages/react-native/Libraries/Lists/FlatList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import type {
VirtualizedListProps,
ViewabilityConfig,
} from '@react-native/virtualized-lists';
import type {ScrollViewComponent} from '../Components/ScrollView/ScrollView';
import type {PublicScrollViewInstance} from '../Components/ScrollView/ScrollView';
import type {StyleProp} from '../StyleSheet/StyleSheet';
import type {ViewStyle} from '../StyleSheet/StyleSheetTypes';
import type {View} from '../Components/View/View';

export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
Expand Down Expand Up @@ -229,13 +228,10 @@ export abstract class FlatListComponent<
getScrollResponder: () => React.JSX.Element | null | undefined;

/**
* Provides a reference to the underlying host component
* Returns a reference to the underlying native scroll view, or null if the
* native instance is not mounted.
*/
getNativeScrollRef: () =>
| React.ComponentRef<typeof View>
| React.ComponentRef<typeof ScrollViewComponent>
| null
| undefined;
getNativeScrollRef: () => PublicScrollViewInstance | null;

getScrollableNode: () => any;

Expand Down