Ramin Khoshravan
Ramin Khoshravan

Reputation: 57

loop for show object value

I wat show the value of the object in view by the loop . how can I do that in react native I don't want to write this

<Label>{this.props.navigation.state.params.item.city}</Label>
<Label>{this.props.navigation.state.params.item.name}</Label>
<Label>{this.props.navigation.state.params.item.family}</Label>
<Label>{this.props.navigation.state.params.item.typofcar}</Label>
...

I want use loop for that . how can I do that?

{ "key": "1", "city": "تهران", "name": "رامین" ,"family": "خوش روان","typofcar": "glx","colorcar": "قرمز","model": "85","flat1": "1",
    "flat2": "0","flat3": "1","flat4": "0", "phone": "023432","mobile": "0125353","adress1": "aggaRWAGARG-WEARG-AERG","adress2": "AWREGARG-WRGAR-",
    "qulity": "55","cards": "GGHHGHH",
    "giftus": "15222","p2": "5142","year": "1364","girbox": "jbbjkl45345","option": "tghhhfrde","price1": "100024"
    ,"pric2": "435453453","perprice": "5554243",
    "daytime": "cxxgfuvyi","ext": "hkudtyjsryjfgjdtyjdtyj","codcar": "564538","codf": "55238735","ostan": "teh","timeofroz": "66",}

Upvotes: 0

Views: 28

Answers (1)

ravibagul91
ravibagul91

Reputation: 20755

You can do this,

Store your object into a variable obj and iterate over this.

Object.keys(obj).forEach(function(key,index) {
    return(
      <Label>{obj[key]}</Label>
    )
});

Upvotes: 1

Related Questions