Skip to content

Commit

Permalink
adding itemIndex variable as index is used twice
Browse files Browse the repository at this point in the history
>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.
facebook#33180 (comment)
  • Loading branch information
fabOnReact committed Mar 11, 2022
1 parent 70e83a2 commit 6bc0f5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,14 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
return (
<View style={StyleSheet.compose(styles.row, columnWrapperStyle)}>
{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 = (
Expand Down

0 comments on commit 6bc0f5a

Please sign in to comment.