From 6bc0f5af7fb24a84cc60e83e99d62546f4c70297 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 11 Mar 2022 18:45:00 +0800 Subject: [PATCH] adding itemIndex variable as index is used twice >now that index is used twice, it would be nice to declare it as a const ex const itemIndex = index * numColumns + kk just to avoid errors where someone changes the calculation on one line but not the other. https://github.com/facebook/react-native/pull/33180#discussion_r820863403 --- Libraries/Lists/FlatList.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 1335d8cf2e5d50..3391036e3cd419 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -614,13 +614,14 @@ class FlatList extends React.PureComponent, void> { return ( {item.map((it, kk) => { + const itemIndex = index * numColumns + kk; const accessibilityCollectionItem = { rowIndex: index, rowSpan: 1, - columnIndex: (index * numColumns + kk) % numColumns, + columnIndex: itemIndex % numColumns, columnSpan: 1, heading: false, - itemIndex: index * numColumns + kk, + itemIndex: itemIndex, }; const element = (