Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Changing the color of a Text item from a FlatList onPress

$
0
0

I have a category list that is being displayed using a FlatList I tried changing the color of a single item OnPress so the user gets a feed back of what item he selected,but all the items in the FlatList change color.

How do I go along about implementing something like this so that the only selected item changes color and gets the original color back when another item is selected

Here is a sample of the code used :

import colors from "../config/colors";function Categories() {  return (<View style={styles.Categories}><FlatList        horizontal        showsHorizontalScrollIndicator={false}        style={{}}        data={category}        keyExtractor={(item) => item.id}        renderItem={({ item }) => {          return <Text style={styles.Text}>{item.title}</Text>;        }}      /></View>  );}

Viewing all articles
Browse latest Browse all 16750

Trending Articles