license import React from 'react' ; import { FlatList , FlatListProps , } from 'react-native' ; import { Overwrite , LiteralUnion } from '../../devsupport' ; import { styled , StyledComponentProps , } from '../../theme' ; type ListStyledProps = Overwrite < StyledComponentProps , { appearance ? : LiteralUnion < 'default' > ; } > ; export type ListProps < ItemT = any > = FlatListProps < ItemT > & ListStyledProps ; export type ListElement < ItemT = any > = React . ReactElement < ListProps < ItemT > > ; export interface BaseScrollParams { animated ? : boolean ; } export interface ViewScrollParams { viewOffset ? : number ; viewPosition ? : number ; } export interface ScrollToIndexParams extends BaseScrollParams , ViewScrollParams { index : number ; } export interface ScrollToOffsetParams extends BaseScrollParams { offset : number ; } extends React . Component property property property overview-example overview-example overview-example overview-example @ styled ( 'List' ) export class List < ItemT = any > extends React . Component < ListProps < ItemT > > { private listRef = React . createRef < FlatList > ( ) ; public scrollToEnd = ( params ? ) : void => { this . listRef . current ?. scrollToEnd ( params ) ; } ; public scrollToIndex = ( params ) : void => { this . listRef . current ?. scrollToIndex ( params ) ; } ; public scrollToOffset ( params ) { this . listRef . current ?. scrollToOffset ( params ) ; } private keyExtractor = ( item , index ) : string => { return index . toString ( ) ; } ; public render ( ) { const { eva , style , keyExtractor , ... flatListProps } = this . props ; return ( < FlatList keyExtractor = { keyExtractor || this . keyExtractor } { ... flatListProps } ref = { this . listRef } style = { [ eva . style , style ] } / > ) ; } }