import {NavigationContainerRef} from '@react-navigation/native'; import * as 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 } }