diff options
Diffstat (limited to 'src/lib/routes/helpers.ts')
-rw-r--r-- | src/lib/routes/helpers.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/routes/helpers.ts b/src/lib/routes/helpers.ts index cdac9039a..7097f09bd 100644 --- a/src/lib/routes/helpers.ts +++ b/src/lib/routes/helpers.ts @@ -1,5 +1,15 @@ +import {NavigationProp} from '@react-navigation/native' import {State, RouteParams} from './types' +export function getRootNavigation<T>( + nav: NavigationProp<T>, +): NavigationProp<T> { + while (nav.getParent()) { + nav = nav.getParent() + } + return nav +} + export function getCurrentRoute(state: State) { let node = state.routes[state.index || 0] while (node.state?.routes && typeof node.state?.index === 'number') { |