diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index da478bf49fc..5a5ddabd9ae 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -100,7 +100,7 @@ type OptionalProps> = {| onEndReached?: ?({distanceFromEnd: number, ...}) => void, |}; -type VirtualizedListProps = React.ElementProps; +type VirtualizedListProps = React.ElementConfig; export type Props = {| ...RequiredProps, @@ -212,11 +212,11 @@ class VirtualizedSectionList< ); } - _getItem = ( + _getItem( props: Props, sections: ?$ReadOnlyArray, index: number, - ): ?Item => { + ): ?Item { if (!sections) { return null; } @@ -238,7 +238,7 @@ class VirtualizedSectionList< } } return null; - }; + } _keyExtractor = (item: Item, index: number) => { const info = this._subExtractor(index); @@ -577,4 +577,11 @@ class ItemWithSeparator extends React.Component< } } -module.exports = VirtualizedSectionList; +module.exports = (VirtualizedSectionList: React.AbstractComponent< + React.ElementConfig, + $ReadOnly<{ + getListRef: () => ?React.ElementRef, + scrollToLocation: (params: ScrollToLocationParamsType) => void, + ... + }>, +>); diff --git a/Libraries/Lists/__tests__/VirtualizedSectionList-test.js b/Libraries/Lists/__tests__/VirtualizedSectionList-test.js index 8a13d7556b4..260da5555f7 100644 --- a/Libraries/Lists/__tests__/VirtualizedSectionList-test.js +++ b/Libraries/Lists/__tests__/VirtualizedSectionList-test.js @@ -103,26 +103,37 @@ describe('VirtualizedSectionList', () => { it('handles separators correctly', () => { const infos = []; - const component = ReactTestRenderer.create( - } - sections={[ - {title: 's0', data: [{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]}, - ]} - renderItem={info => { - infos.push(info); - return ; - }} - getItem={(data, key) => data[key]} - getItemCount={data => data.length} - />, - ); + let component; + ReactTestRenderer.act(() => { + component = ReactTestRenderer.create( + } + sections={[ + {title: 's0', data: [{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]}, + ]} + renderItem={info => { + infos.push(info); + return ; + }} + getItem={(data, key) => data[key]} + getItemCount={data => data.length} + />, + ); + }); expect(component).toMatchSnapshot(); - infos[1].separators.highlight(); + + ReactTestRenderer.act(() => { + infos[1].separators.highlight(); + }); expect(component).toMatchSnapshot(); - infos[2].separators.updateProps('leading', {press: true}); + ReactTestRenderer.act(() => { + infos[2].separators.updateProps('leading', {press: true}); + }); + expect(component).toMatchSnapshot(); + ReactTestRenderer.act(() => { + infos[1].separators.unhighlight(); + }); expect(component).toMatchSnapshot(); - infos[1].separators.unhighlight(); }); it('handles nested lists', () => { diff --git a/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap b/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap index 8adaf474b43..d0fc9fa107c 100644 --- a/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap +++ b/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap @@ -596,6 +596,140 @@ exports[`VirtualizedSectionList handles separators correctly 3`] = ` `; +exports[`VirtualizedSectionList handles separators correctly 4`] = ` + + + + + + + + + + + + + + + + + + + + + +`; + exports[`VirtualizedSectionList renders all the bells and whistles 1`] = `