I have a FlatList.
I want to add comma between items.
Currently working like this;
If there is only one item;
Mon,
If there are multiple items;
Mon, Tue, Wed,
My code;
<FlatList
data={job.schedule}
renderItem={({ item, index }) => (
<View style={[[Layout.center], {}]}>
<Text style={[[Fonts.textInterRegular12]]}>
{item.dayHuman.slice(0, 3)}{', '}
</Text>
</View>
)}
horizontal
keyExtractor={item => item.id}
extraData={this.state}
showsVerticalScrollIndicator={false}
/>
Above code has two issues.
If there is only one item, I don't want to add a comma.
E.g. Mon
If there are multiple items, I don't want to add a comma next to the last item.
E.g. Mon, Tue, Wed
How can I achieve this?
