about summary refs log tree commit diff
path: root/src/lib/routes
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-05-28 18:38:52 -0700
committerGitHub <noreply@github.com>2024-05-29 02:38:52 +0100
commit8f8af476cca54ad26b214e56af022b392d8f9389 (patch)
tree4f5fc2668501c1b0d9f008f2446493e590262a9e /src/lib/routes
parent888bec7b4fbe1b924d788333ec44c916fd3e8676 (diff)
downloadvoidsky-8f8af476cca54ad26b214e56af022b392d8f9389.tar.zst
Bump `react-navigation` (#4216)
* bump and rm patch

* fix types

* use `Home` default

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/lib/routes')
-rw-r--r--src/lib/routes/helpers.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/routes/helpers.ts b/src/lib/routes/helpers.ts
index 0da885043..603b6f71b 100644
--- a/src/lib/routes/helpers.ts
+++ b/src/lib/routes/helpers.ts
@@ -1,5 +1,6 @@
 import {NavigationProp} from '@react-navigation/native'
-import {State, RouteParams} from './types'
+
+import {RouteParams, State} from './types'
 
 export function getRootNavigation<T extends {}>(
   nav: NavigationProp<T>,
@@ -10,7 +11,11 @@ export function getRootNavigation<T extends {}>(
   return nav
 }
 
-export function getCurrentRoute(state: State) {
+export function getCurrentRoute(state?: State) {
+  if (!state) {
+    return {name: 'Home'}
+  }
+
   let node = state.routes[state.index || 0]
   while (node.state?.routes && typeof node.state?.index === 'number') {
     node = node.state?.routes[node.state?.index]