(this.state.categories.includes(e.value)) {
let remove = this.state.categories.filter(cat => cat.value != e.value)
await this.setState({ categories: remove })
} else {
await this.setState(prev => ({ categories: [ ...prev.categories, e ], [e.value]: !prev[e.value] }) )
}
console.warn(this.state.categories);
}
}
// here is the render
{
Data.specialities.map(category => (
<TouchableOpacity key={ category.value } onPress={ () => this.check(category) } style={ styles.list_container }>
<View style={ styles.icon_container }>
{
this.state[category.value]
? <Icon name="md-checkmark" style={ styles.icon } />
: null
}
</View>
<Text style={ styles.category }>{ category.value }</Text>
</TouchableOpacity>
))
}
It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.
Обсуждают сегодня