From 78bdf0e4e2cbbd94b0fc4efb6aec528d84d8db4d Mon Sep 17 00:00:00 2001 From: Miguel Alatzar Date: Wed, 24 Jul 2019 09:51:36 -0700 Subject: [PATCH] Check initialIndex in callback (#3025) --- app/components/post_list/post_list.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/components/post_list/post_list.js b/app/components/post_list/post_list.js index 693817a82..c2209ec04 100644 --- a/app/components/post_list/post_list.js +++ b/app/components/post_list/post_list.js @@ -201,10 +201,8 @@ export default class PostList extends PureComponent { }; handleScrollToIndexFailed = () => { - requestAnimationFrame(() => { - this.hasDoneInitialScroll = false; - this.scrollToInitialIndexIfNeeded(1, 1); - }); + this.hasDoneInitialScroll = false; + this.scrollToInitialIndexIfNeeded(1, 1); }; handleSetScrollToBottom = () => { @@ -290,11 +288,10 @@ export default class PostList extends PureComponent { if ( width > 0 && height > 0 && - this.props.initialIndex > 0 && !this.hasDoneInitialScroll ) { requestAnimationFrame(() => { - if (this.flatListRef?.current) { + if (this.props.initialIndex > 0 && this.flatListRef?.current) { this.flatListRef.current.scrollToIndex({ animated: false, index: this.props.initialIndex,