I'm using react-native FlatList to render out a punch on elements the data of which comes from an external API.
I want to prevent the user from picking the same item twice. So the way I'm going about this it hiding the item after they pick it.
If, let's say, I have a state picked
like so
const [ picked, setPicked ] = useState(false);
changing it will of course hide all the elements.
<FlatList {/*some other props*/} data={allCards} renderItem={(card: ListRenderItemInfo<CardsProps>) => (<TouchableOpacity style={[ styles.holder, { display: picked ? "none" : "flex" } ]} onPress={() => handleChoice(parseInt(card.item.id))}><Card {/*some card props*/} /></TouchableOpacity> )} />
How can I go about changing the state for only one element inside the FlatList??Is there a better approach you would recommend to do the same job?