Skip to content

Commit

Permalink
refactor(utils): upd. navigate types
Browse files Browse the repository at this point in the history
  • Loading branch information
zheleznov163 committed Sep 12, 2022
1 parent 53379f8 commit 23219bc
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions navigation/utils.ts
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)
}

0 comments on commit 23219bc

Please sign in to comment.