Skip to content

Commit

Permalink
fix: useSelectedTab broken behaviour (#10421)
Browse files Browse the repository at this point in the history
fix: useSelectedTab
  • Loading branch information
MounirDhahri committed Jun 21, 2024
1 parent 9e76222 commit c1fd2cf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/utils/hooks/useSelectedTab.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { useNavigationState } from "@react-navigation/native"
import { __unsafe_mainModalStackRef } from "app/NativeModules/ARScreenPresenterModule"
import { BottomTabType } from "app/Scenes/BottomTabs/BottomTabType"

export function useSelectedTab(): BottomTabType {
const tabState = __unsafe_mainModalStackRef.current
const tabState = useNavigationState(
(state) => state.routes.find((r) => r.state?.type === "tab")?.state
)

const _unsafe_tabState = __unsafe_mainModalStackRef.current
?.getState()
?.routes.find((r) => r.state?.type === "tab")?.state

if (!tabState) {
if (!tabState || !_unsafe_tabState) {
return "home"
} else {
const { index, routes } = tabState
const { index, routes } = tabState || _unsafe_tabState
if (index === undefined) {
return "home"
}
Expand Down

0 comments on commit c1fd2cf

Please sign in to comment.