diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index f24aaf5fb..28932e5bc 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -178,8 +178,6 @@ type Props = RequiredProps & OptionalProps & VirtualizedLis const defaultProps = { ...VirtualizedList.defaultProps, - getItem: undefined, - getItemCount: undefined, numColumns: 1, }; type DefaultProps = typeof defaultProps; diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index bd955f4b2..1a9f33438 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -38,6 +38,14 @@ type RequiredProps = { * getItem, getItemCount, and keyExtractor to handle any type of index-based data. */ data?: any, + /** + * A generic accessor for extracting an item from any sort of data blob. + */ + getItem: (data: any, index: number) => ?Item, + /** + * Determines how many items are in the data blob. + */ + getItemCount: (data: any) => number, }; type OptionalProps = { /** @@ -57,14 +65,6 @@ type OptionalProps = { * `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) => ?Item, - /** - * Determines how many items are in the data blob. - */ - getItemCount: (data: any) => number, getItemLayout?: (data: any, index: number) => {length: number, offset: number, index: number}, // e.g. height, y horizontal?: ?boolean, @@ -254,8 +254,6 @@ class VirtualizedList extends React.PureComponent { static defaultProps = { disableVirtualization: false, - getItem: (data: any, index: number) => data[index], - getItemCount: (data: any) => data ? data.length : 0, horizontal: false, initialNumToRender: 10, keyExtractor: (item: Item, index: number) => { diff --git a/Libraries/Lists/__tests__/VirtualizedList-test.js b/Libraries/Lists/__tests__/VirtualizedList-test.js index 2f3376498..8134a0aca 100644 --- a/Libraries/Lists/__tests__/VirtualizedList-test.js +++ b/Libraries/Lists/__tests__/VirtualizedList-test.js @@ -23,6 +23,8 @@ describe('VirtualizedList', () => { } + getItem={(data, index) => data[index]} + getItemCount={(data) => data.length} /> ); expect(component).toMatchSnapshot(); @@ -33,6 +35,8 @@ describe('VirtualizedList', () => { } + getItem={(data, index) => data[index]} + getItemCount={(data) => data.length} /> ); expect(component).toMatchSnapshot(); @@ -43,6 +47,8 @@ describe('VirtualizedList', () => { } + getItem={(data, index) => data[index]} + getItemCount={(data) => 0} /> ); expect(component).toMatchSnapshot(); @@ -55,6 +61,8 @@ describe('VirtualizedList', () => { ListFooterComponent={() =>