-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(utils): upd. navigate types
- Loading branch information
1 parent
53379f8
commit 23219bc
Showing
1 changed file
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { NavigationContainerRef } from "@react-navigation/native"; | ||
import { createRef } from "react"; | ||
import { RootStackParamList } from "types"; | ||
import { NavigationContainerRef } from "@react-navigation/native" | ||
import { createRef } from "react" | ||
import { RootStackParamList } from "types" | ||
|
||
export const navigationRef = createRef<NavigationContainerRef<RootStackParamList>>() | ||
|
||
export function getMainNavigation() | ||
{ | ||
return navigationRef.current ? navigationRef.current : undefined | ||
export function getMainNavigation() { | ||
return navigationRef.current ? navigationRef.current : undefined | ||
} | ||
|
||
export function navigate(name: keyof RootStackParamList, params?:any) { | ||
navigationRef.current?.navigate<keyof RootStackParamList>(name, params); | ||
} | ||
export function navigate<T extends keyof RootStackParamList>( | ||
name: T, | ||
params?: RootStackParamList[T], | ||
) { | ||
navigationRef.current?.navigate<keyof RootStackParamList>(name, params) | ||
} |