Call scrollToIndex only if flatListRef.current is not null (#3023)
This commit is contained in:
parent
0a93ec134c
commit
e214039cee
1 changed files with 9 additions and 8 deletions
|
|
@ -291,16 +291,17 @@ export default class PostList extends PureComponent {
|
|||
width > 0 &&
|
||||
height > 0 &&
|
||||
this.props.initialIndex > 0 &&
|
||||
!this.hasDoneInitialScroll &&
|
||||
this.flatListRef?.current
|
||||
!this.hasDoneInitialScroll
|
||||
) {
|
||||
requestAnimationFrame(() => {
|
||||
this.flatListRef.current.scrollToIndex({
|
||||
animated: false,
|
||||
index: this.props.initialIndex,
|
||||
viewOffset: 0,
|
||||
viewPosition: 1, // 0 is at bottom
|
||||
});
|
||||
if (this.flatListRef?.current) {
|
||||
this.flatListRef.current.scrollToIndex({
|
||||
animated: false,
|
||||
index: this.props.initialIndex,
|
||||
viewOffset: 0,
|
||||
viewPosition: 1, // 0 is at bottom
|
||||
});
|
||||
}
|
||||
});
|
||||
this.hasDoneInitialScroll = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue