5
Does Reactnative Listview accept an array of arrays ? Because I need to receive the API data as follows :
[[{"userId":1,"userName":"Ricardo"},{"userId":1,"userName":"Ricardo"}],[{"userId":1,"userName":"Ricardo"},{"userId":1,"userName":"Ricardo"}]].
I made the following code to display it :
renderRowUsers(rowData, sectionID, rowID) {
return rowData.map(function(user, i){
return(
<View key={i}>
<Text>{user.userId}</Text>
<View>
<Text>{user.userName}</Text>
</View>
</View>
);
});
}
and
const usersDS = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1.user !== r2.user
});
this.state = {
usersDataSource: usersDS.cloneWithRows([{
"userId": "",
"userName": "Ricardo"
}])
}
<ListView
style={{paddingTop: 2, height:100}}
dataSource={this.state.usersDataSource}
renderRow={this.renderRowUsers.bind(this)}
/>
But it returns me the following error :
"Staticrender.Reder():A Valid React element(or null) must be retorned. You may have returned Undefined, an array or some other invalid Object."
You can show the code of
ListView
? gives me idea that this array ofthis.renderRowUsers
should go inside the jsx ofListView
– Sergio
I added in the code, I was in doubt what to put in rowHasChanged , as it will compare the arrays ?
– Ricardo Mendes
It would be better to put your (s) complete Component(s), so pieces of it is difficult to know how the logic is.
– Sergio