Skip to content

Action Sheet Patch #5823

@mosestenai

Description

@mosestenai

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/native-base/src/hooks/useKeyboardDismissable.ts b/node_modules/native-base/src/hooks/useKeyboardDismissable.ts
index f3cfa44..bf73475 100644
--- a/node_modules/native-base/src/hooks/useKeyboardDismissable.ts
+++ b/node_modules/native-base/src/hooks/useKeyboardDismissable.ts
@@ -44,16 +44,16 @@ export const useKeyboardDismissable = ({ enabled, callback }: IParams) => {
 
 export function useBackHandler({ enabled, callback }: IParams) {
   useEffect(() => {
-    let backHandler = () => {
+    if (!enabled) return;
+
+    const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
       callback();
       return true;
+    });
+
+    return () => {
+      subscription?.remove?.(); // ✅ This is the correct way in RN 0.72+
     };
-    if (enabled) {
-      BackHandler.addEventListener('hardwareBackPress', backHandler);
-    } else {
-      BackHandler.removeEventListener('hardwareBackPress', backHandler);
-    }
-    return () =>
-      BackHandler.removeEventListener('hardwareBackPress', backHandler);
   }, [enabled, callback]);
 }
+

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions