react-native-flash-message icon indicating copy to clipboard operation
react-native-flash-message copied to clipboard

onPress not triggered with TouchableWithoutFeedback - Pressable works

Open JeffreyVanelderenACA opened this issue 1 year ago • 0 comments

Hi,

Not sure if anyone else is having this issue but my onPress passed to showMessage config doesn't trigger.

I'm having this issue since I'm using this library and created this patch a while ago (since version 4.0.0 or even earlier I'm using this patch in my projects)

Current version: [email protected] , but should also work for some earlier versions as stated above

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-flash-message/src/FlashMessage.js b/node_modules/react-native-flash-message/src/FlashMessage.js
index 29891b6..8ff5c5c 100644
--- a/node_modules/react-native-flash-message/src/FlashMessage.js
+++ b/node_modules/react-native-flash-message/src/FlashMessage.js
@@ -1,5 +1,14 @@
 import React, { Component } from "react";
-import { StyleSheet, TouchableWithoutFeedback, Platform, StatusBar, Animated, Image, Text, View } from "react-native";
+import {
+  StyleSheet,
+  Platform,
+  StatusBar,
+  Animated,
+  Image,
+  Text,
+  View,
+  Pressable
+} from "react-native";
 import { isIphoneX, getStatusBarHeight } from "react-native-iphone-screen-helper";
 import PropTypes from "prop-types";
 
@@ -625,7 +634,7 @@ export default class FlashMessage extends Component {
     return (
       <Animated.View pointerEvents="box-none" style={[positionStyle(styles.root, position), animStyle]}>
         {!!message && (
-          <TouchableWithoutFeedback onPress={this.pressMessage} onLongPress={this.longPressMessage} accessible={false}>
+          <Pressable onPress={this.pressMessage} onLongPress={this.longPressMessage} accessible={false}>
             <MessageComponent
               position={position}
               floating={floating}
@@ -647,7 +656,7 @@ export default class FlashMessage extends Component {
               accessibilityLabel={accessibilityLabel}
               testID={testID}
             />
-          </TouchableWithoutFeedback>
+          </Pressable>
         )}
       </Animated.View>
     );

This issue body was partially generated by patch-package.

JeffreyVanelderenACA avatar Oct 25 '23 13:10 JeffreyVanelderenACA