Browse Source

Fix incorrect extraction of navigationHelpers.

Herby Vojčík 6 years ago
parent
commit
56b58417f7
1 changed files with 7 additions and 3 deletions
  1. 7 3
      index.js

+ 7 - 3
index.js

@@ -34,17 +34,21 @@ export const backButtonHandler = ({dispatch, getState}) => {
     return true;
 };
 
+const topOfNavigationStack = ({routes}) => routes[routes.length - 1] || {};
+const isRoute = expected => ({routeName}) => routeName === expected;
+const isTopRoute = expected => state => isRoute(expected)(topOfNavigationStack(state));
+
 export const navigationHelpers = {
-    topOfNavigationStack: ({routes}) => routes[routes.length - 1] || {},
+    topOfNavigationStack,
 
     resetRoutes: routeNames => reset({
         actions: routeNames.map(routeName => navigate({routeName})),
         index: routeNames.length - 1
     }),
 
-    isRoute: expected => ({routeName}) => routeName === expected,
+    isRoute,
 
-    isTopRoute: expected => state => isRoute(expected)(topOfNavigationStack(state)),
+    isTopRoute,
 
     goBackFrom: routeName => ({dispatch, getState}) => {
         if (isTopRoute(routeName)(getState())) {