jeudi 28 septembre 2017

React-native if condition in List Item

I have List that render an array how can i put an if condition statement ?.. for example

if (item.ticketId === 2) { and in the if statement the data render will be in different color }

do I need to create another function ?

           <Content>
                <ScrollView>
                <List>
                  { this.state.ticket.map((item, i) => (
                    <ListItem
                    roundAvatar
                    key={i}
                    avatar={
                      <View >
                        <Text>{item.ticketId}</Text>
                      </View>
                    }
                      title={
                        <View>
                          <Text>ROW :{item.row}</Text>
                        </View>
                      }
                      subtitle={
                        <View>
                          <Text>GATE :{item.gate}</Text>
                        </View>
                      }
                    />
                  ))
                  }
                  </List>
                </ScrollView>
              </Content>

Aucun commentaire:

Enregistrer un commentaire