deleteItemById = id => { const filteredData = this.state.data.filter(item => item.id !== id); this.setState({ data: filteredData }); } render() { ... return ( <FlatList data={data} // Assuming this is `this.state.data` keyExtractor={({item}) => item.id} renderItem={({item}) => ( <View style={styles.container}> <SwipeView ... onSwipedLeft={() => this.deleteItemById(item.id)} ... /> </View> )} /> ); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter