From 3831c75653545f2618c88a68c4c399366392ff2b Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Sat, 14 Nov 2020 09:36:42 +0530 Subject: [PATCH 1/5] Added Prop: initialNumToRender --- .../rn-tester/js/examples/SectionList/SectionListExample.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExample.js b/packages/rn-tester/js/examples/SectionList/SectionListExample.js index b00cc81c71e1..f94a407c7592 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExample.js +++ b/packages/rn-tester/js/examples/SectionList/SectionListExample.js @@ -84,6 +84,7 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { logViewable: false, virtualized: true, inverted: false, + itemsToRender: 10, }; _scrollPos = new Animated.Value(0); @@ -174,6 +175,7 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { renderSectionHeader={renderSectionHeader} renderSectionFooter={renderSectionFooter} stickySectionHeadersEnabled + initialNumToRender={this.state.itemsToRender} sections={[ { key: 'empty section', From c130538c45be01877a94d351abfd77beffb072b0 Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Sat, 14 Nov 2020 10:00:58 +0530 Subject: [PATCH 2/5] Added Prop: ListEmptyComponent --- .../js/examples/SectionList/SectionListExample.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExample.js b/packages/rn-tester/js/examples/SectionList/SectionListExample.js index f94a407c7592..730607ee2b7e 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExample.js +++ b/packages/rn-tester/js/examples/SectionList/SectionListExample.js @@ -67,6 +67,12 @@ const CustomSeparatorComponent = ({highlighted, text}) => ( ); +const EmptySectionList = () => ( + + This is rendered when the list is empty + +); + class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { state: | any @@ -176,6 +182,7 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { renderSectionFooter={renderSectionFooter} stickySectionHeadersEnabled initialNumToRender={this.state.itemsToRender} + ListEmptyComponent={EmptySectionList} sections={[ { key: 'empty section', From 801a3bd5ae8e6a1435a784f21e6d5d69158d3bf0 Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Sat, 14 Nov 2020 10:13:16 +0530 Subject: [PATCH 3/5] Added Prop: onEndReached --- .../rn-tester/js/examples/SectionList/SectionListExample.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExample.js b/packages/rn-tester/js/examples/SectionList/SectionListExample.js index 730607ee2b7e..e29cc4778e26 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExample.js +++ b/packages/rn-tester/js/examples/SectionList/SectionListExample.js @@ -183,6 +183,12 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { stickySectionHeadersEnabled initialNumToRender={this.state.itemsToRender} ListEmptyComponent={EmptySectionList} + onEndReached={() => { + Alert.alert( + 'onEndReached called', + 'You have reached the end of this list', + ); + }} sections={[ { key: 'empty section', From 13097fa5977791370bae3f3d4630f6ab7da55850 Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Sat, 14 Nov 2020 12:17:12 +0530 Subject: [PATCH 4/5] Added Prop: onEndReachedThreshold to list --- .../js/examples/SectionList/SectionListExample.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExample.js b/packages/rn-tester/js/examples/SectionList/SectionListExample.js index e29cc4778e26..5c96f1fde717 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExample.js +++ b/packages/rn-tester/js/examples/SectionList/SectionListExample.js @@ -183,12 +183,13 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { stickySectionHeadersEnabled initialNumToRender={this.state.itemsToRender} ListEmptyComponent={EmptySectionList} - onEndReached={() => { + onEndReached={() => Alert.alert( 'onEndReached called', 'You have reached the end of this list', - ); - }} + ) + } + onEndReachedThreshold={0} sections={[ { key: 'empty section', From ac7eff6caab79901b4d7e728bb041068541c13e6 Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Wed, 25 Nov 2020 08:31:37 +0530 Subject: [PATCH 5/5] Fixed Flow errors on iOS and Android --- .../rn-tester/js/examples/SectionList/SectionListExample.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExample.js b/packages/rn-tester/js/examples/SectionList/SectionListExample.js index 5c96f1fde717..239372b57499 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExample.js +++ b/packages/rn-tester/js/examples/SectionList/SectionListExample.js @@ -90,7 +90,6 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { logViewable: false, virtualized: true, inverted: false, - itemsToRender: 10, }; _scrollPos = new Animated.Value(0); @@ -181,7 +180,7 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { renderSectionHeader={renderSectionHeader} renderSectionFooter={renderSectionFooter} stickySectionHeadersEnabled - initialNumToRender={this.state.itemsToRender} + initialNumToRender={10} ListEmptyComponent={EmptySectionList} onEndReached={() => Alert.alert(