diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-14 16:36:08 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-04-14 16:36:08 -0400 |
commit | 51baf2073e884a1585756993237d54bdad35b774 (patch) | |
tree | 8e4052e758e35915612d76989f5ed138f25b19b3 /src/RootNavigation.ts | |
parent | 0c6a50bb54499dca981e0ca72da6f1bfbbf0d724 (diff) |
added logic to log screen views
Diffstat (limited to 'src/RootNavigation.ts')
-rw-r--r-- | src/RootNavigation.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/RootNavigation.ts b/src/RootNavigation.ts index 827177a3..56ccfca4 100644 --- a/src/RootNavigation.ts +++ b/src/RootNavigation.ts @@ -1,5 +1,5 @@ import {NavigationContainerRef} from '@react-navigation/native'; -import * as React from 'react'; +import React from 'react'; export const navigationRef: React.RefObject<NavigationContainerRef> = React.createRef(); @@ -13,3 +13,14 @@ export function navigate(name: string) { // Ignore this, or add these actions to a queue you can call later } } + +export const getActiveRouteName = (state) => { + const route = state.routes[state?.index || 0]; + + if (route.state) { + // Dive into nested navigators + return getActiveRouteName(route.state); + } + + return route.name; +}; |