diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-14 23:13:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-14 23:13:20 -0400 |
commit | 2051515252c335ff71242830bdbd30331ab783d1 (patch) | |
tree | 529b0815c81e0f44c7fc13b6d9206c2aed61c0bc /src/RootNavigation.ts | |
parent | be07e46929587244adfb816fa8a5170af267a976 (diff) | |
parent | 51baf2073e884a1585756993237d54bdad35b774 (diff) |
Merge pull request #366 from IvanIFChen/tma778-add-analytics
[TMA-778] Add Analytics
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; +}; |