I'm new to React Native` and I've been trying to create a view with the number of buttons dynamically created from the data that I fetch from the API.
One of my problems is that the data that is returned doesn't have any name that I can point like item.number.
First I tried to do a <Flatlist/> but I wasn't getting the design that I wanted, like this:

so now I'm trying to make in a different way, but I'm always getting the error:
Cannot read property '0' of undefined
data.json:
{
"sEcho":0,
"iTotalRecords":"75",
"iTotalDisplayRecords":"73",
"aaData":[
[
"1",
"1",
"Consumidor Final",
"999999990",
"",
"",
null,
", ",
"21110000",
"1",
"1",
"1"
],
[
"2",
"1000",
"xxxxxx",
"xxxxx",
"",
"",
null,
", ",
"xxxx",
"15",
"1",
"1"
]
]
}
How I am fetching the data;
getClientes = async (token, opcao, search, pag, numRows) => {
var url = "https://xxxx/xxxx/xxx/xxxx/xxx/tabelas/clientes?_token=" + token + "&opcao= " + opcao + "&search=&pag=&numRows=" + numRows;
fetch(url)
.then((response) => response.json())
.then((responseJson) => {
this.setState({
dataSource: responseJson.aaData,
isLoading: false,
numRows: responseJson.iTotalDisplayRecords
})
console.log(responseJson.iTotalDisplayRecords + " total");
console.log("CLIENTES: " + responseJson.aaData[0][2]);
console.log(this.state.dataSource[0][2]);
})
.catch((error) => {
console.log(error);
})
}
How I render the buttons:
renderClientes = (numRows, data) => {
console.log(numRows + "azxcvb");
console.log(data.length + "render Clientes");
const views = [];
for (let i = 0; i <= numRows; i++) {
for (let j = 0; j <= 11; j++) {
views.push(
<TouchableOpacity style={{ flex: 1, flexDirection: 'row', marginBottom: 3 }} key={i}>
<View style={{ flex: 1, justifyContent: 'center', marginLeft: 5 }}>
<Text style={{ fontSize: 18, color: 'green' }}>
{data[i][j]}
</Text>
</View>
</TouchableOpacity>
);
}
}
return views;
}
then:
render() {
return (
...
(this.state.numRows != 0) ? this.renderClientes(this.state.numRows, this.state.dataSource) : null)
}
How can I solve my problem? And if there is any easier way to do this, what is?

