Reputation: 4425
The function that called while rendering a module.Also I read somewhere to use Arrow
function but I believe arrow function already in form code, is it ?
onRemoveCard = item => {
return () =>
this.props.removeModal(
'Remove Card',
'Are you sure want to remove this card?',
);
};
A render item component from the FlatList
.
<CardTile
onRemove={this.onRemoveCard(item)}
subtitle={autoReoladBalance}
addGiftCard={false}
/>
How can this should be stopped for call while I am rendering item? It should be called onPress
.
Upvotes: 0
Views: 874
Reputation: 5023
You are calling this.onRemoveCard(item)
while passing props in CardTile
, instead, you should pass reference like
<CardTile
onRemove={this.onRemoveCard} /* passing reference instead of calling*/
subtitle={autoReoladBalance}
addGiftCard={false}
/>
Hope this will help!
Upvotes: 1