From 81ca7edca2c370eb984a91ce97fd42ab5a4a18ee Mon Sep 17 00:00:00 2001 From: Yousef Date: Mon, 19 Mar 2018 10:54:47 +0100 Subject: [PATCH 1/2] BackHandlerStatic returns NativeEventSubscription --- types/react-native/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 5abf96e04c..bbceb07226 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6550,7 +6550,7 @@ export interface BackAndroidStatic { */ export interface BackHandlerStatic { exitApp(): void; - addEventListener(eventName: BackPressEventName, handler: () => void): void; + addEventListener(eventName: BackPressEventName, handler: () => void): NativeEventSubscription; removeEventListener(eventName: BackPressEventName, handler: () => void): void; } From 79c3fcfe44a3d2a3adac9bb0bef068fd586603f8 Mon Sep 17 00:00:00 2001 From: Yousef El-Dardiry Date: Mon, 19 Mar 2018 19:35:02 +0100 Subject: [PATCH 2/2] add test for backhandler --- types/react-native/test/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 879a0c522d..65db445695 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -17,6 +17,7 @@ import { AppState, AppStateIOS, BackAndroid, + BackHandler, Button, DataSourceAssetCallback, DeviceEventEmitterStatic, @@ -73,6 +74,8 @@ function testDimensions() { Dimensions.removeEventListener('change', dimensionsListener); } +BackHandler.addEventListener("hardwareBackPress", () => {}).remove(); + BackAndroid.addEventListener("hardwareBackPress", () => {}); interface LocalStyles {