Reputation: 157
I have a flatlist and it's working fine, I'm trying to put a function inside the code that is rendering my item but it gives me an error, and i need to put the function there so i can read the item's properties, here is my code:
_renderItem ({ item, index}) {
_shareText() {
Share.share({
message: item.name,
})
}
return (
<Button title="Share" onPress={this._shareText}/>
);
}
Upvotes: 0
Views: 1575
Reputation: 334
try this, i can see that _shareText is not defined like a function in the component
_shareText(item) {
Share.share({
message: item.name,
})
}
_renderItem({ item, index }) {
return (
<Button title="Share" onPress={() => { this._shareText(item); }} />
);
}
Upvotes: 1