import { createRef } from 'react' ; import { NavigationContainerRef , StackActions } from '@react-navigation/native' ; export const navigationRef = createRef < NavigationContainerRef > ( ) ; export const isMountedRef = createRef ( ) ; interface NavigateProps { ( name , params ) : void ; } export const navigate = ( name , params ) => { if ( isMountedRef . current && navigationRef . current ) { navigationRef . current . navigate ( name , params ) ; } else { } } ; export const navigatePop = ( ) : void => { if ( isMountedRef . current && navigationRef . current ) { navigationRef . current ?. dispatch ( StackActions . pop ( ) ) ; } else { } } ; export const popToTop = ( ) : void => { if ( isMountedRef . current && navigationRef . current ) { navigationRef . current ?. dispatch ( StackActions . popToTop ( ) ) ; } else { } } ;