11import * as React from "react" ;
2- import { StackActions } from "@react-navigation/native" ;
2+ import { NavigationContainerRef , StackActions } from "@react-navigation/native" ;
33
4- export const isReadyRef = React . createRef ( ) ;
5- export const navigationRef = React . createRef ( ) ;
4+ export let isReadyRef = React . createRef < any > ( ) ;
5+ export let navigationRef = React . createRef < NavigationContainerRef > ( ) ;
66
77export const navigate = ( routeName : string , params ?: any ) => {
88 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
99 // Perform navigation if the app has mounted
10- navigationRef ?. current . navigate ( routeName , params ) ;
10+ navigationRef ?. current ? .navigate ( routeName , params ) ;
1111 }
1212} ;
1313
14- export const push = ( routeName : string , params ?: any , ... args : any ) => {
14+ export const push = ( routeName : string , params ?: any ) => {
1515 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
1616 // Perform navigation if the app has mounted
17- navigationRef . current . dispatch (
18- StackActions . push ( routeName , params , ...args ) ,
19- ) ;
17+ navigationRef . current . dispatch ( StackActions . push ( routeName , params ) ) ;
2018 }
2119} ;
2220
23- export const goBack = ( ... args : any ) => {
21+ export const goBack = ( ) => {
2422 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
2523 // Perform navigation if the app has mounted
26- navigationRef . current . goBack ( ... args ) ;
24+ navigationRef . current . goBack ( ) ;
2725 }
2826} ;
2927
@@ -34,10 +32,10 @@ export const pop = (...args: any) => {
3432 }
3533} ;
3634
37- export const popToTop = ( ... args : any ) => {
35+ export const popToTop = ( ) => {
3836 if ( isReadyRef . current && navigationRef && navigationRef . current ) {
3937 // Perform navigation if the app has mounted
40- navigationRef . current ?. dispatch ( StackActions . popToTop ( ... args ) ) ;
38+ navigationRef . current ?. dispatch ( StackActions . popToTop ( ) ) ;
4139 }
4240} ;
4341
0 commit comments