@@ -2,6 +2,7 @@ import * as React from "react";
22import {
33 createNavigationContainerRef ,
44 StackActions ,
5+ TabActions ,
56} from "@react-navigation/native" ;
67
78interface RefObject < T > {
@@ -44,7 +45,7 @@ export const addNavigationListener = (
4445} ;
4546
4647export const isReadyRef : RefObject < boolean > = React . createRef < boolean > ( ) ;
47- export const navigationRef = createNavigationContainerRef < any > ( ) ;
48+ export const navigationRef = createNavigationContainerRef ( ) ;
4849
4950export const navigationListenerProps = {
5051 onTransitionEnd : ( props , ...args ) =>
@@ -59,30 +60,27 @@ export const navigationListenerProps = {
5960 executeNavigationListeners ( "gestureCancel" , ...args ) ,
6061} ;
6162
62- export const navigate = ( routeName : string , params ?: any ) => {
63+ export const navigate = ( routeName , params ) => {
6364 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
64- // Perform navigation if the app has mounted
65+ // @ts -ignore
6566 navigationRef ?. current ?. navigate ( routeName , params ) ;
6667 }
6768} ;
6869
6970export const push = ( routeName : string , params ?: any ) => {
7071 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
71- // Perform navigation if the app has mounted
7272 navigationRef . current . dispatch ( StackActions . push ( routeName , params ) ) ;
7373 }
7474} ;
7575
7676export const goBack = ( ) => {
7777 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
78- // Perform navigation if the app has mounted
7978 navigationRef . current . goBack ( ) ;
8079 }
8180} ;
8281
8382export const pop = ( ...args : any ) => {
8483 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
85- // Perform navigation if the app has mounted
8684 navigationRef . current ?. dispatch ( StackActions . pop ( ...args ) ) ;
8785 }
8886} ;
@@ -96,14 +94,18 @@ export const popToTop = () => {
9694
9795export const reset = ( params : any ) => {
9896 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
99- // Perform navigation if the app has mounted
10097 navigationRef . current ?. reset ( params ) ;
10198 }
10299} ;
103100
104101export const replace = ( params : any ) => {
105102 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
106- // Perform navigation if the app has mounted
107- navigationRef . current ?. replace ( params ) ;
103+ navigationRef . current ?. dispatch ( StackActions . replace ( params ) ) ;
104+ }
105+ } ;
106+
107+ export const jumpTo = ( params : any ) => {
108+ if ( isReadyRef . current && navigationRef && navigationRef . current ) {
109+ navigationRef . current ?. dispatch ( TabActions . jumpTo ( params ) ) ;
108110 }
109111} ;
0 commit comments