From 57b211cea3ac9ddfff9b0fa61f36af18a12d2544 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Thu, 1 Jul 2021 09:28:49 +0300 Subject: [PATCH] Chain listRef.current optionally Signed-off-by: Lauri Nevala --- src/renderer/components/virtual-list/virtual-list.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/virtual-list/virtual-list.tsx b/src/renderer/components/virtual-list/virtual-list.tsx index c5a32edc43..4c3594f255 100644 --- a/src/renderer/components/virtual-list/virtual-list.tsx +++ b/src/renderer/components/virtual-list/virtual-list.tsx @@ -75,7 +75,7 @@ export class VirtualList extends Component { const { items, rowHeights } = this.props; if (prevProps.items.length !== items.length || !isEqual(prevProps.rowHeights, rowHeights)) { - this.listRef.current.resetAfterIndex(0, false); + this.listRef.current?.resetAfterIndex(0, false); } } @@ -87,11 +87,11 @@ export class VirtualList extends Component { const index = items.findIndex(item => item.getId() == selectedItemId); if (index === -1) return; - this.listRef.current.scrollToItem(index, "start"); + this.listRef.current?.scrollToItem(index, "start"); }); scrollToItem = (index: number, align: Align) => { - this.listRef.current.scrollToItem(index, align); + this.listRef.current?.scrollToItem(index, align); }; render() {