I have an array of days, which I am mapping in my View
but I am getting warning that Warning: Each child in a list should have a unique "key" prop.
, I am not able to understand why I am getting this error. I am new to react native, and I am trying to understand what every warning means
my code:
<ScrollView
horizontal={true}
showsHorizontalScrollIndicator={false}
contentContainerStyle={styles.horizontalView}>
{weekArray.map((item, index) => (
<TouchableOpacity index={index} onPress={() => setIndexSelect(index)}>
<Text
style={{
fontFamily: "Raleway-Regular",
fontSize: SizeConfig.blockHeight * 2.1,
color: indexSelect === index ? COLORS.blackDark : COLORS.blackLight,
}}>
{index === weekArray.length - 1 ? ` ${item.day} ` : ` ${item.day} | `}
</Text>
</TouchableOpacity>
))}
</ScrollView>;