From 7bfb4a0a546bbddf5b322a803cad28782c534296 Mon Sep 17 00:00:00 2001 From: Garamani <47912427+Garamani@users.noreply.github.com> Date: Sun, 4 Apr 2021 22:46:39 +0430 Subject: [PATCH] setTimeout to delay the scrollTo It seems that ScrollView has a layout animation, and without delaying the "scrollTo" It won't scroll to the end of the list. Using the componentDidMount approach, the delay should be at least 500 ms but delaying "scrollTo" in "onLayoutScrollView" only 1 ms is enough to scroll to the end of a large List (The delay was raised to 100ms to be sure that ScrollView is ready for scrollTo ). Replacing the ScrollView with FlatList might be a better choice to improve the performance. --- src/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index fa413de..746c061 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -157,7 +157,9 @@ export default class HorizontalPicker extends PureComponent { + this.refScrollView.current.scrollTo({ x, y: 0, animated: false }); + }, 100); } }