Null check on current (#3316)
This commit is contained in:
parent
cdc020fc9c
commit
6b4b4ce75f
2 changed files with 5 additions and 3 deletions
|
|
@ -299,7 +299,7 @@ export default class PostList extends PureComponent {
|
|||
|
||||
scrollToBottom = () => {
|
||||
setTimeout(() => {
|
||||
if (this.flatListRef?.current) {
|
||||
if (this.flatListRef.current) {
|
||||
this.flatListRef.current.scrollToOffset({offset: 0, animated: true});
|
||||
}
|
||||
}, 250);
|
||||
|
|
@ -316,7 +316,7 @@ export default class PostList extends PureComponent {
|
|||
|
||||
scrollToIndex = (index) => {
|
||||
this.animationFrameInitialIndex = requestAnimationFrame(() => {
|
||||
if (this.flatListRef?.current && index > 0 && index <= this.getItemCount()) {
|
||||
if (this.flatListRef.current && index > 0 && index <= this.getItemCount()) {
|
||||
this.flatListScrollToIndex(index);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ describe('PostList', () => {
|
|||
const indexInRange = baseProps.postIds.length;
|
||||
const indexOutOfRange = [-1, indexInRange + 1];
|
||||
|
||||
instance.flatListRef = {};
|
||||
instance.flatListRef = {
|
||||
current: null,
|
||||
};
|
||||
instance.scrollToIndex(indexInRange);
|
||||
expect(flatListScrollToIndex).not.toHaveBeenCalled();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue