Necesito verificar dónde existe la matriz de datos en el bucle de lista plana,
ejemplo
const renderItem = ({ item }) => ( <TouchableOpacity> <Text>{item.name}<Text> <Text>i Want to show this Text only in array 2,4,6,8,...<Text> </TouchableOpacity> ); <FlatList data={product} renderItem={renderItem} keyExtractor={item => item.id} ListEmptyComponent={(<EmptyData />)} style={{ flex: 1, marginBottom: 50 }} />Necesito mostrar el texto pero solo en la longitud de la matriz 2,4,6,8,..., ya intenté usar el producto [2] pero el texto muestra cada bucle
Supongo que desea que el texto se muestre cuando la longitud del product sea pareja. Para eso puedes usar el siguiente código:
const renderItem = ({ item }) => ( <TouchableOpacity> <Text>{item.name}<Text> {(product.length % 2) === 0 && <Text>i Want to show this Text only in array 2,4,6,8,...<Text>} </TouchableOpacity> );