Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onPress not triggered with TouchableWithoutFeedback - Pressable works #268

Open
JeffreyVanelderenACA opened this issue Oct 25, 2023 · 0 comments

Comments

@JeffreyVanelderenACA
Copy link

JeffreyVanelderenACA commented Oct 25, 2023

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 JeffreyVanelderenACA changed the title onPress not triggerd with TouchableWithoutFeedback - Pressable works onPress not triggered with TouchableWithoutFeedback - Pressable works Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant