fix: mobx out of bounds read warning

This commit is contained in:
Aman Harwara
2022-11-07 13:25:43 +05:30
committed by GitHub
parent a7569333de
commit 34b3f67b2a

View File

@@ -111,8 +111,12 @@ const ContentList: FunctionComponent<Props> = ({
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 (
<ContentListItem
key={item.uuid}