In my app, i have a flat list in my app and there is a button I want to add not in the whole flatlist but some of the list components so that's why i need to call the key id of that specific component to the function. Here is the code of flat list. ** <FlatList
data={this.state.dataSource}
renderItem={this.renderItem}
// keyExtractor= {(item,index) => index}
keyExtractor={item => item.GameId.toString()}
ItemSeparatorComponent={this.renderSeprator}
refreshing = {this.state.refreshing}
onRefresh = {this.handleRefresh}
handlePress={item => item.GameId.toString()}
/>
** This is the function where i want to call gameID ** handlePress = () => {
if( this.GameId == 1){
this.setState({
btnvalue1: 'flex'});
console.log('ssss11');
} else {
this.setState({
btnvalue1: 'none'});
}
}
**
You can do like below
Code
Hope this helps !!!
Snack expo link