Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 139833

How to display JSON data in react-native without a list?

$
0
0

Good afternoon. I comprehend the development of an application on a reactive native, I encountered a problem with displaying data.

From the server side comes json

[
  {
    "cell_name": "112185",
    "id": "000000005",
    "pallets": [
      {
        "id": "000000016",
        "items": [
          {
            "product_info": {
              "name": "first product name",
              "unit_info": {
                "name": "box"
              },
            },
            "count": 100
          },
          {
            "product_info": {
              "name": "second product name",
              "unit_info": {
                "name": "box"
              },
            },
            "count": 23
          },
          {
            "product_info": {
              "name": "third product name",
              "unit_info": {
                "name": "box"
              },
            },
            "count": 15
          }
        ]
      }
    ]
  }
]

I need to display information on the screen.

I tried to display in this way, but I failed - nothing is displayed.

return (
        <PageView
             ...
        >
            <View>

                    { cells.map((cell, cell_i) => {
                        const cell_name = cell.name == '' ? 'Not cell' : cell.name;
                        return (<Text key={cell_i}>Cell {cell_name}</Text> &&
                            ( for (i in cell.pallets) {
                                const pallet = cell.pallets[i];
                                const pallet_name = pallet.id == '' ? 'Not pallet' : pallet.id;
                                return (<Text h2 key={cell_i+'.'+pallet_i}>Pallet {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>
        )

Perhaps someone will tell you how to display such a structure correctly?


Viewing all articles
Browse latest Browse all 139833

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>