Added definition for VirtualizedListProps.

This commit is contained in:
Tommy Nguyen
2017-08-07 16:47:01 +02:00
parent 1514d1b834
commit f1f3e5e89d

View File

@@ -3486,7 +3486,7 @@ interface ListRenderItemInfo<ItemT> {
type ListRenderItem<ItemT> = (info: ListRenderItemInfo<ItemT>) => React.ReactElement<any> | null
export interface FlatListProperties<ItemT> extends ScrollViewProperties {
export interface FlatListProperties<ItemT> extends VirtualizedListProperties<ItemT> {
/**
* Rendered in between each item, but not at the top or bottom
@@ -3525,7 +3525,7 @@ export interface FlatListProperties<ItemT> extends ScrollViewProperties {
* For simplicity, data is just a plain array. If you want to use something else,
* like an immutable list, use the underlying VirtualizedList directly.
*/
data: ItemT[] | null;
data: ReadonlyArray<ItemT> | null;
/**
* A marker property for telling the list to re-render (since it implements PureComponent).
@@ -3798,6 +3798,163 @@ export interface SectionListStatic<SectionT> extends React.ComponentClass<Sectio
}
/**
* @see https://facebook.github.io/react-native/docs/virtualizedlist.html#props
*/
export interface VirtualizedListProperties<ItemT> extends ScrollViewProperties {
/**
* Rendered when the list is empty. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListEmptyComponent?: React.ComponentClass<any> | React.ReactElement<any> | (() => React.ReactElement<any>) | null
/**
* Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListFooterComponent?: React.ComponentClass<any> | React.ReactElement<any> | (() => React.ReactElement<any>) | null
/**
* Rendered at the top of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListHeaderComponent?: React.ComponentClass<any> | React.ReactElement<any> | (() => React.ReactElement<any>) | null
/**
* The default accessor functions assume this is an Array<{key: string}> but you can override
* getItem, getItemCount, and keyExtractor to handle any type of index-based data.
*/
data?: any
/**
* `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
* implementation, but with a significant perf hit.
*/
debug?: boolean
/**
* DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
* unmounts react instances that are outside of the render window. You should only need to disable
* this for debugging purposes.
*/
disableVirtualization?: boolean
/**
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
* `data` prop, stick it here and treat it immutably.
*/
extraData?: any
/**
* A generic accessor for extracting an item from any sort of data blob.
*/
getItem?: (data: any, index: number) => ItemT
/**
* Determines how many items are in the data blob.
*/
getItemCount?: (data: any) => number
getItemLayout?: (data: any, index: number) => {
length: number,
offset: number,
index: number
}
horizontal?: boolean
/**
* How many items to render in the initial batch. This should be enough to fill the screen but not
* much more. Note these items will never be unmounted as part of the windowed rendering in order
* to improve perceived performance of scroll-to-top actions.
*/
initialNumToRender?: number
/**
* Instead of starting at the top with the first item, start at `initialScrollIndex`. This
* disables the "scroll to top" optimization that keeps the first `initialNumToRender` items
* always rendered and immediately renders the items starting at this initial index. Requires
* `getItemLayout` to be implemented.
*/
initialScrollIndex?: number
/**
* Reverses the direction of scroll. Uses scale transforms of -1.
*/
inverted?: boolean
keyExtractor?: (item: ItemT, index: number) => string
/**
* The maximum number of items to render in each incremental render batch. The more rendered at
* once, the better the fill rate, but responsiveness my suffer because rendering content may
* interfere with responding to button taps or other interactions.
*/
maxToRenderPerBatch?: number
onEndReached?: (info: {distanceFromEnd: number}) => void
onEndReachedThreshold?: number // units of visible length
onLayout?: () => void
/**
* If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make
* sure to also set the `refreshing` prop correctly.
*/
onRefresh?: () => void
/**
* Called when the viewability of rows changes, as defined by the
* `viewabilityConfig` prop.
*/
onViewableItemsChanged?: ((info: {viewableItems: Array<ViewToken>, changed: Array<ViewToken>}) => void) | null
/**
* Set this when offset is needed for the loading indicator to show correctly.
* @platform android
*/
progressViewOffset?: number
/**
* Set this true while waiting for new data from a refresh.
*/
refreshing?: boolean | null
/**
* Note: may have bugs (missing content) in some circumstances - use at your own risk.
*
* This may improve scroll performance for large lists.
*/
removeClippedSubviews?: boolean
renderItem: ListRenderItem<ItemT>
/**
* Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
*/
renderScrollComponent?: (props: ScrollViewProperties) => React.ReactElement<ScrollViewProperties>
/**
* Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
* screen. Similar fill rate/responsiveness tradeoff as `maxToRenderPerBatch`.
*/
updateCellsBatchingPeriod?: number
viewabilityConfig?: ViewabilityConfig
/**
* Determines the maximum number of items rendered outside of the visible area, in units of
* visible lengths. So if your list fills the screen, then `windowSize={21}` (the default) will
* render the visible screen area plus up to 10 screens above and 10 below the viewport. Reducing
* this number will reduce memory consumption and may improve performance, but will increase the
* chance that fast scrolling may reveal momentary blank areas of unrendered content.
*/
windowSize?: number
}
/**
* @see https://facebook.github.io/react-native/docs/listview.html#props
*/