Skip to content

Commit

Permalink
Production deployment (#1056)
Browse files Browse the repository at this point in the history
**Only merge using a merge commit!**
  • Loading branch information
simonknittel authored Jan 6, 2025
2 parents 66e4057 + 51cef9f commit 6308b40
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions app/src/common/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
"use client";

import NextLink from "next/link";
import { useRouter } from "next/navigation";
import type { ComponentProps } from "react";
import { useState, type ComponentProps } from "react";

type Props = ComponentProps<typeof NextLink>;

export const Link = (props: Props) => {
const { prefetch, href, onMouseEnter, ...rest } = props;
const router = useRouter();
const { prefetch, onMouseEnter, ...rest } = props;

const [_prefetch, setPrefetch] = useState(
prefetch === undefined ? false : prefetch,
);

const _prefetch = prefetch === undefined ? false : prefetch;
const _onMouseEnter =
prefetch === undefined && onMouseEnter === undefined
? () => router.prefetch(typeof href === "string" ? href : href.href)
? () => setPrefetch(true)
: onMouseEnter;

return (
<NextLink
href={href}
prefetch={_prefetch}
onMouseEnter={_onMouseEnter}
{...rest}
/>
<NextLink prefetch={_prefetch} onMouseEnter={_onMouseEnter} {...rest} />
);
};

0 comments on commit 6308b40

Please sign in to comment.