From 1cffd83a4e3fabaf8aae9c1dcc8162e7623ad582 Mon Sep 17 00:00:00 2001 From: Julian Hundeloh Date: Wed, 14 Aug 2019 17:11:00 +0200 Subject: [PATCH 1/2] fix: catch undefined navigation --- src/Hooks.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Hooks.ts b/src/Hooks.ts index 6fe37fc..0fc9c70 100644 --- a/src/Hooks.ts +++ b/src/Hooks.ts @@ -32,6 +32,10 @@ export function useNavigationEvents(handleEvt: NavigationEventCallback) { const navigation = useNavigation(); useEffect( () => { + if (!navigation) { + return + } + const subsA = navigation.addListener( 'action' as any // TODO should we remove it? it's not in the published typedefs , handleEvt); From 31a83ef89283f005cdb0478e1c42d4e73864c05a Mon Sep 17 00:00:00 2001 From: Julian Hundeloh Date: Wed, 14 Aug 2019 20:00:08 +0200 Subject: [PATCH 2/2] style: fix lint --- src/Hooks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Hooks.ts b/src/Hooks.ts index 0fc9c70..371b957 100644 --- a/src/Hooks.ts +++ b/src/Hooks.ts @@ -33,9 +33,9 @@ export function useNavigationEvents(handleEvt: NavigationEventCallback) { useEffect( () => { if (!navigation) { - return + return; } - + const subsA = navigation.addListener( 'action' as any // TODO should we remove it? it's not in the published typedefs , handleEvt);