import {NavigationContainerRef} from '@react-navigation/native'; import React from 'react'; export const navigationRef: React.RefObject = React.createRef(); export function navigate(name: string) { if (navigationRef.current) { // Perform navigation if the app has mounted //console.log('Reached root navigation'); navigationRef.current.navigate(name); } else { // TODO: Decide what to do if the app hasn't mounted // 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; };