GeekyAnts / GeekyAnts/NativeBase

Error in backHandler Expo 53

Open
#5,825 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
20.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used [patch-package](https://github.com/ds300/patch-package) to patch `native-base@3.4.28` for the project I'm working on.

i fixed an issue in Expo 53

Here is the diff that solved my problem:

```diff
diff --git a/node_modules/native-base/src/hooks/useKeyboardDismissable.ts b/node_modules/native-base/src/hooks/useKeyboardDismissable.ts
index f3cfa44..1ceedaf 100644
--- a/node_modules/native-base/src/hooks/useKeyboardDismissable.ts
+++ b/node_modules/native-base/src/hooks/useKeyboardDismissable.ts
@@ -44,16 +44,20 @@ export const useKeyboardDismissable = ({ enabled, callback }: IParams) => {

export function useBackHandler({ enabled, callback }: IParams) {
useEffect(() => {
- let backHandler = () => {
- callback();
- return true;
- };
+ let subscription: any;
+
if (enabled) {
- BackHandler.addEventListener('hardwareBackPress', backHandler);
- } else {
- BackHandler.removeEventListener('hardwareBackPress', backHandler);
+ const handler = () => {
+ callback();
+ return true;
+ };
+
+ subscription = BackHandler.addEventListener('hardwareBackPress', handler);
+
+ return () => {
+ subscription?.remove?.(); // ← Este es el nuevo estándar
+ };
}
- return () =>
- BackHandler.removeEventListener('hardwareBackPress', backHandler);
}, [enabled, callback]);
}
+
```

This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.