Answer the question
In order to leave comments, you need to log in
How to display JSON data in react-native without a list?
Good afternoon. I'm learning how to develop an application in react native, I ran into a problem with displaying data.
json coming from server side
[
{
"cell_name": "112185",
"id": "000000005",
"pallets": [
{
"id": "000000016",
"items": [
{
"product_info": {
"name": "Ванилин 1,5 гр",
"unit_info": {
"name": "шт"
},
},
"count": 100
},
{
"document_uid": "a520c7b5-e990-11e9-ab43-005056ab6dbf",
"product_info": {
"name": "Огурцы конс. 0,72 1/12",
"unit_info": {
"name": "шт"
},
},
"count": 23
},
{
"document_uid": "a520c7b5-e990-11e9-ab43-005056ab6dbf",
"product_info": {
"name": "Опята конс. 370 г. 1/12",
"unit_info": {
"name": "шт"
},
},
"count": 15
}
]
}
]
}
]
return (
<PageView
...
>
<View>
{ cells.map((cell, cell_i) => {
const cell_name = cell.name == '' ? 'Без ячейки' : cell.name;
return (<Text key={cell_i}>Ячейка {cell_name}</Text> &&
( for (i in cell.pallets) {
const pallet = cell.pallets[i];
const pallet_name = pallet.id == '' ? 'Без паллеты' : pallet.id;
return (<Text h2 key={cell_i+'.'+pallet_i}>Паллета {pallet_name}</Text> &&
( for(j in pallet.items) {
const item = pallet.items[j];
return (<Text key={cell_i+'.'+pallet_i+'.'+item_i}>{item.product_info.name} {item.count} {item.product_info.unit_info.name}</Text>);
})
)
})
)
})}
</View>
</PageView>
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question