From 34b3f67b2a4521783063d31f1b3aa1bee1bb91ea Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Mon, 7 Nov 2022 13:25:43 +0530 Subject: [PATCH] fix: mobx out of bounds read warning --- .../Components/ContentListView/ContentList.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/web/src/javascripts/Components/ContentListView/ContentList.tsx b/packages/web/src/javascripts/Components/ContentListView/ContentList.tsx index 475c9abb9..b53002907 100644 --- a/packages/web/src/javascripts/Components/ContentListView/ContentList.tsx +++ b/packages/web/src/javascripts/Components/ContentListView/ContentList.tsx @@ -111,8 +111,12 @@ const ContentList: FunctionComponent = ({ tabIndex={FOCUSABLE_BUT_NOT_TABBABLE} > {items.map((item, index) => { - const previousItem = items[index - 1] - const nextItem = items[index + 1] + const previousIndex = index - 1 + const previousItem = previousIndex >= 0 ? items[previousIndex] : undefined + + const nextIndex = index + 1 + const nextItem = nextIndex < items.length ? items[nextIndex] : undefined + return (