Files
Jyotisha/frontend/src/components/app-link.tsx
T

34 lines
907 B
TypeScript

"use client";
import Link from "next/link";
import { forwardRef, type ComponentProps } from "react";
import { hrefFromLinkTarget, interceptAppNavigation } from "@/lib/app-navigation";
export type AppLinkProps = ComponentProps<typeof Link>;
/**
* In-app link that stays on the client router when this tab's build matches
* the running image, and does a document load when it does not.
*
* Next 16.3.1's own mismatch fallback did not fire on this host after a
* deploy (see BUG-967); wrapping the destinations that actually no-op'd is
* the self-heal.
*/
export const AppLink = forwardRef<HTMLAnchorElement, AppLinkProps>(function AppLink(
{ onClick, href, ...props },
ref,
) {
return (
<Link
ref={ref}
href={href}
onClick={(event) => {
onClick?.(event);
interceptAppNavigation(event, hrefFromLinkTarget(href));
}}
{...props}
/>
);
});