From 45a5c626532acd09857b6610be09d05442c01233 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Tue, 5 Jun 2018 19:50:42 -0400 Subject: [PATCH] [react-navigation] Add index to NavigationLeafRoute --- types/react-navigation/index.d.ts | 4 ++++ .../react-navigation-tests.tsx | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index ef4904c11f..dd9efa0de4 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -96,6 +96,10 @@ export interface NavigationLeafRoute { * they will be defined by the router. */ key: string; + /** + * Index that represents the depth of the stack + */ + index: number; /** * For example 'Home'. * This is used as a key in a route config when creating a navigator. diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index b59474bd11..9697e61de8 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -6,6 +6,7 @@ import { } from 'react-native'; import { createDrawerNavigator, + createBottomTabNavigator, DrawerNavigatorConfig, NavigationAction, NavigationActions, @@ -451,3 +452,20 @@ class Page2 extends React.Component { return { this.navigatorRef = instance; }} />; } } + +const BottomStack = createBottomTabNavigator({ + Posts: { + screen: Page2, + navigationOptions: ({ navigation }: NavigationScreenProps) => { + let tabBarVisible = true; + + if (navigation.state.index > 0) { + tabBarVisible = false; + } + + return { + tabBarVisible + }; + } + } +});