From 248238dda8ef08396dd717e07b443d3fd18ae48b Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Fri, 31 Dec 2021 12:09:03 +0100 Subject: [PATCH] Try to fix scrollToIndex out of range --- src/screens/Tabs/Shared/Toot.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/screens/Tabs/Shared/Toot.tsx b/src/screens/Tabs/Shared/Toot.tsx index 825cbff3..94a77a99 100644 --- a/src/screens/Tabs/Shared/Toot.tsx +++ b/src/screens/Tabs/Shared/Toot.tsx @@ -38,12 +38,13 @@ const TabSharedToot: React.FC> = ({ if (!scrolled.current) { scrolled.current = true const pointer = findIndex(flattenData, ['id', toot.id]) - setTimeout(() => { - flRef.current?.scrollToIndex({ - index: pointer === -1 ? 0 : pointer, - viewOffset: 100 - }) - }, 500) + pointer > 0 && + setTimeout(() => { + flRef.current?.scrollToIndex({ + index: pointer, + viewOffset: 100 + }) + }, 1000) } } })