BlueWallet/NavigationService.ts
2024-05-21 11:56:10 +01:00

25 lines
652 B
TypeScript

import { createNavigationContainerRef, NavigationAction, ParamListBase } from '@react-navigation/native';
export const navigationRef = createNavigationContainerRef<ParamListBase>();
export function navigate(name: string, params?: ParamListBase) {
if (navigationRef.isReady()) {
navigationRef.current?.navigate(name, params);
}
}
export function dispatch(action: NavigationAction) {
if (navigationRef.isReady()) {
navigationRef.current?.dispatch(action);
}
}
export function reset() {
if (navigationRef.isReady()) {
navigationRef.current?.reset({
index: 0,
routes: [{ name: 'UnlockWithScreenRoot' }],
});
}
}