2021-09-13 20:41:05 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import { CommonActions, NavigationContainerRef, StackActions } from '@react-navigation/native';
|
|
|
|
|
2022-06-01 19:46:37 +00:00
|
|
|
// TODO: we need change this any to the correctly types from our stacks
|
|
|
|
const navigationRef = React.createRef<NavigationContainerRef<any>>();
|
|
|
|
const routeNameRef: React.MutableRefObject<NavigationContainerRef<any> | null> = React.createRef();
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
function navigate(name: string, params?: any) {
|
|
|
|
navigationRef.current?.navigate(name, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
function back() {
|
|
|
|
navigationRef.current?.dispatch(CommonActions.goBack());
|
|
|
|
}
|
|
|
|
|
|
|
|
function replace(name: string, params: any) {
|
|
|
|
navigationRef.current?.dispatch(StackActions.replace(name, params));
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
navigationRef,
|
|
|
|
routeNameRef,
|
|
|
|
navigate,
|
|
|
|
back,
|
|
|
|
replace
|
|
|
|
};
|