0

I have developed chat view in React Native using gifted chat lib. But i want to perform delete action on click of chat bubble.

I have try custom renderCustomView ,lightboxProps and onLongPress props but none of is working.

Rajesh N
  • 6,198
  • 2
  • 47
  • 58

1 Answers1

8

add onLongPress to GiftedChat component like this

<GiftedChat
       onLongPress={this.onLongPress}
    
       ....
       ....
/>

onLongPress returns context, message. Then you can show an ActionSheet and add your logic to delete.


    onLongPress(context, message) {
        console.log(context, message);
        const options = ['Delete Message', 'Cancel'];
        const cancelButtonIndex = options.length - 1;
        context.actionSheet().showActionSheetWithOptions({
            options,
            cancelButtonIndex
        }, (buttonIndex) => {
            switch (buttonIndex) {
                case 0:
                    // Your delete logic
                    break;
                case 1:
                    break;
            }
        });
    }
Nam Vu
  • 5,669
  • 7
  • 58
  • 90