I'm trying to delete an item from a list in react native but its not working
handleDeletePost = (passedItem) => {
const { userPosts } = this.state;
const newArray = userPosts.map(item => {
if (item.headline === passedItem.headline) {
Alert.alert(
'Delete Post',
'Are you sure to delete Post?',
[
{text: 'Yes', onPress: () => console.log('Ask me later pressed')},
{text: 'No', onPress: () => console.log('Cancel Pressed'), style: 'cancel'}
],
{ cancelable: false }
)
}
});
}
When i hit delete i get an error: can't find variable index
map. It would be nice to try first to find the element you want to remove and the youArray.sliceit out afteronPressconfirmation.