Hyperlinkv0.9.0-beta.0

ui/Navigator

ui/Navigator.Providerconstsrc/ui/Navigator.ts:205
(props: {
  readonly value: Service
  readonly children: React.ReactNode
}): React.ReactElement

Provide a live Service to descendant skins (used by ../View.compose).

Service../View.compose
export const Provider = (props: {
  readonly value: Service;
  readonly children: React.ReactNode;
}): React.ReactElement => {
  const { value } = props;
  React.useEffect(() => {
    if (value.mode !== "history" || typeof window === "undefined") return;
    value.syncFromLocation();
    const onPop = (): void => value.syncFromLocation();
    window.addEventListener("popstate", onPop);
    return () => window.removeEventListener("popstate", onPop);
  }, [value]);
  return React.createElement(
    NavigatorReactContext.Provider,
    { value },
    props.children,
  );
};