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() {