Answer the question
In order to leave comments, you need to log in
How to use hooks in a loop?
There is a list of blocks. It is necessary to make it so that when you click, the style of this block changes. I don't know how to implement it. I know that this cannot be done in a loop due to the possibility of breaking the order of the hooks, but how can this be done?
<FlatList
data={arr}
numColumns={7}
renderItem={item => {
item.state = 'noActive';
console.log(item);
return (
<TouchableWithoutFeedback
onPress={() => (item.state = 'active')}
style={styles.fullContainer}>
<View style={[styles.block, styles[item.state]]}>
<Text>{item.item.name}</Text>
</View>
</TouchableWithoutFeedback>
);
}}
/>
Answer the question
In order to leave comments, you need to log in
but how can this be done?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question