(): ServiceRead the parent Navigator service. Re-renders on path changes.
Source src/ui/Navigator.ts:2299 lines
export const const useNavigator: () => ServiceRead the parent
Navigator
service. Re-renders on path changes.
useNavigator = (): Service => {
const const nav: Service | nullnav = React.function React.useContext<Service | null>(context: React.Context<Service | null>): Service | nullAccepts a context object (the value returned from React.createContext) and returns the current
context value, as given by the nearest context provider for the given context.
useContext(const NavigatorReactContext: React.Context<Service | null>NavigatorReactContext);
if (const nav: Service | nullnav === null) {
throw new var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+1 overload)
Error("Navigator: render inside View.compose(…).Provider (or Navigator.Provider)");
}
const [, const bump: React.ActionDispatch<[]>bump] = React.function React.useReducer<number, []>(reducer: (prevState: number) => number, initialState: number): [number, React.ActionDispatch<[]>] (+1 overload)An alternative to useState.
useReducer is usually preferable to useState when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch down instead of callbacks.
useReducer((n: numbern: number) => n: numbern + 1, 0);
React.function React.useEffect(effect: React.EffectCallback, deps?: React.DependencyList): voidAccepts a function that contains imperative, possibly effectful code.
useEffect(() => const nav: Serviceconst nav: {
root: RouteGroup;
mode: "memory" | "history";
path: ReadonlyArray<string>;
trail: ReadonlyArray<RouteGroup>;
group: RouteGroup;
selected: unknown | null;
view: string | undefined;
open: (member: MemberTag) => void;
openKey: (key: string) => void;
back: () => void;
toRoot: () => void;
openLogs: (tag: LeafTag) => void;
openSchedule: (tag: LeafTag) => void;
subscribe: (listener: () => void) => () => void;
syncFromLocation: () => void;
}
nav.Service.subscribe: (listener: () => void) => () => voidsubscribe(const bump: React.ActionDispatch<[]>bump), [const nav: Serviceconst nav: {
root: RouteGroup;
mode: "memory" | "history";
path: ReadonlyArray<string>;
trail: ReadonlyArray<RouteGroup>;
group: RouteGroup;
selected: unknown | null;
view: string | undefined;
open: (member: MemberTag) => void;
openKey: (key: string) => void;
back: () => void;
toRoot: () => void;
openLogs: (tag: LeafTag) => void;
openSchedule: (tag: LeafTag) => void;
subscribe: (listener: () => void) => () => void;
syncFromLocation: () => void;
}
nav]);
return const nav: Serviceconst nav: {
root: RouteGroup;
mode: "memory" | "history";
path: ReadonlyArray<string>;
trail: ReadonlyArray<RouteGroup>;
group: RouteGroup;
selected: unknown | null;
view: string | undefined;
open: (member: MemberTag) => void;
openKey: (key: string) => void;
back: () => void;
toRoot: () => void;
openLogs: (tag: LeafTag) => void;
openSchedule: (tag: LeafTag) => void;
subscribe: (listener: () => void) => () => void;
syncFromLocation: () => void;
}
nav;
};