Here In my code customerSearch is an array I am getting some value. Now I am trying to map this value in such way like if it display on UI ,it should be in group according to the key.
Like customer is a key inside that key there is array and two value is there, so first customer come and bellow that two array value and after that again next key and their values. Same for other key.
customerSearch[
{
"key": "customer",
"data": [
{
"name": "John",
"status": "Active",
"nationalId": "NBGVH6676"
},
{ "name": "Abhi",
"status": "Active",
"nationalId": "NBGVH6890"}
]
},
{
"key": "requests",
"data": [
{
"name": "Kartik",
"status": "Active",
"nationalId": "K0089"
},
{ "name": "Ashi",
"status": "Active",
"nationalId": "AS420"
}
]
},
{
"key": "invoice",
"data": [
{
"name": "John",
"status": "Active",
"nationalId": "IN998"
},
{ "name": "Abhi2",
"status": "Active",
"nationalId": "ABh007"
}
]
},
{
"key": "offering",
"data": [
{},
{}
]
}
]
Below code in render function
<View style={{ marginLeft: 5, marginRight: 5, marginTop: 10, backgroundColor: '#f1f1f1' }}>
{this.props.customerSearch.map(
(data, index) => {
return (
<View style={{ marginBottom: 10, marginLeft: 5, marginRight: 5 }} key={index}>
<Card>
<CardItem header style={{ backgroundColor: '#fff', width: '100%', justifyContent: 'space-between', borderBottomColor: '#f1f1f1', borderBottomWidth: 1 }}>
<View style={{ flexDirection: 'column', justifyContent: 'space-between' }}>
<View>
<RegularText text={`${data.key}`} style={{ fontWeight: 'bold', flexWrap: 'wrap' }} />
<SmallText text={` Name ${""}`} textColor="grey" />
<SmallText text={` Status ${""}`} textColor="grey" />
<SmallText text={` NationalId ${""}`} textColor="grey" />
</View>
</View>
</CardItem>
</Card>
</View>
);
})
}
</View>
Example UI display
Customer
Name
Status
National ID
Name
Status
National ID
Request
Name
Status
National ID
Name
Status
National ID