react-native-speedy-list
Version:
A performance focused list component for React Native.
116 lines (115 loc) • 3.66 kB
TypeScript
import React from "react";
import { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent } from "react-native";
import { RecyclableItem } from "../RecyclableItem";
import { RecyclableListItemInternalMeta, RecyclableListProps } from "./types";
export declare class RecyclableList<T = any> extends React.Component<RecyclableListProps<T>> {
static defaultProps: {
itemEquals: <T_1>(a: T_1, b: T_1) => boolean;
recyclingDelay: number;
initialBatchSize: number;
recyclableItemsCount: number;
onEndReachedOffset: number;
};
/**
* True after the first render.
* */
rendered: boolean;
/**
* Used to dynamic calculate the recycled height.
* */
windowHeight: number;
/**
* Auto updated using header view onLayout.
* */
headerHeight: number;
/**
* Sum of all items heights.
* */
itemsHeightSum: number;
/**
* Mean item height.
* */
meanItemHeight: number;
/**
* Current scroll position.
* */
scrollY: number;
/**
* Current scrolling speed.
* */
scrollSpeed: number;
/**
* Scroll layout info.
* */
scrollHeight: number;
scrollContentHeight: number;
lastOnEndReachedContentHeight: number;
/**
* Amount of recyclable items. It should be enough to cover
* at least two times the screen size, in order to avoid blank
* spaces when scrolling.
* */
recyclableViewCount: number;
/**
* Dictionary of indexes and refs for each recycled view.
* */
recyclableRefsDict: Record<number, RecyclableItem<T> | null>;
/**
* Current items as a dictionary and as a list for ease access.
* */
itemsDict: Record<string, RecyclableListItemInternalMeta<T>>;
itemsList: RecyclableListItemInternalMeta<T>[];
itemCount: number;
/**
* Helper to show debug logs.
* */
_debug: (...args: Array<any>) => void;
constructor(props: RecyclableListProps<T>);
shouldComponentUpdate(nextProps: Readonly<RecyclableListProps<T>>): boolean;
/**
* Updating recycled views each list update.
* */
componentDidUpdate(): void;
/**
* Returns the recycled views.
* */
_getContent: () => Array<React.ReactElement>;
/**
* Returns which items should be
* currently recycled.
* */
_getRecycledItems: (limit?: number) => Array<RecyclableListItemInternalMeta<T>>;
_validateItemRef: (items: Array<RecyclableListItemInternalMeta<T>>, item: RecyclableListItemInternalMeta<T>, refIndex: number) => boolean;
/**
* Handle scroll changes.
* */
_onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
/**
* Watches scroll layout changes.
* */
_onScrollLayout: (event: LayoutChangeEvent) => void;
/**
* Watches scroll content layout changes.
* */
_onScrollContentChange: (width: number, height: number) => void;
_checkOnEndReached: () => void;
/**
* Handles header layout changes.
* */
_onHeaderLayout: (event: LayoutChangeEvent) => void;
/**
* Updates which ref should handle each list item.
* */
_updateRefs: (items: Array<RecyclableListItemInternalMeta<T>>) => void;
/**
* Updates the list metadata.
* */
_updateMeta: (props?: RecyclableListProps<T> | undefined) => void;
/**
* Updating recycled views for the next
* predicted scroll position.
* */
_updateContent: (limit?: number) => void;
_updateContentThrottled: import("../../util/ThrottlingUtil/types").Func<void | null>;
render(): React.ReactElement;
}