React Native - If within List data loop render

287 views Asked by At

I have an array of data which I am displaying in a list using <List dataArray=

Inside of this loop I want to do some conditional checks to determine whether to display something e.g.

<List dataArray={ this.state.appointments } renderRow={(data) =>
    <View>
        #Need to set a variable inside conditional so it only displays once if there are multiple on the same date.
        {data.start_actual == formatted_today ?
            <ListItem itemDivider style={{backgroundColor: 'crimson'}}>
                <Text style={{color: 'white'}}>Today</Text>
            </ListItem> : null }          

          <ListItem>
            <Left style={{flex: 0.4}}>
              <Text>{data.name}</Text>
            </Left>
          </ListItem>
    </View>
</List>

The two values in my if are read as "text" rather than "variables", how do I change that? And how do I set a variable within the conditional statement so i can set it if it gets inside so it doesn't render it twice?

Thanks

0

There are 0 answers