Hi all so currently I am making a service for my application/library i am creating and so far this is the best way I can figure out how to create a service. Ideally I would like to change this method into a variable for easier reading
import { NavigationRoute, NavigationParams } from 'react-navigation';
import { NavigationStackProp } from 'react-navigation-stack';
type Navigation =
| NavigationStackProp<NavigationRoute<NavigationParams>, NavigationParams>
| undefined;
export default class NavigationService {
private static _navigator: Navigation;
public static setNavigator(navigatorRef: Navigation) {
this._navigator = navigatorRef;
}
public static navigate = (): Navigation => {
// TODO: look into how to make this a variable
return NavigationService._navigator;
};
}
currently i have this
IconPress: () => NavigationService.navigate()?.openDrawer()
but would love for it to read like this
IconPress: () => NavigationService.navigate?.openDrawer()