Skip to content

Commit 86222c7

Browse files
author
Nicolas Dorseuil
committed
add comment
1 parent c1badb4 commit 86222c7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ export async function RecordCard(
165165

166166
if (target && targetRef) {
167167
return (
168+
// We don't use `Link` directly here because we could end up in a situation where
169+
// a link is rendered inside a link, which is not allowed in HTML.
170+
// It causes an hydration error in React.
168171
<LinkBox href={target.href} className={tcls(style, 'hover:before:ring-tint-12/5')}>
169172
<LinkOverlay
170173
href={target.href}

packages/gitbook/src/components/primitives/Link.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export const Link = React.forwardRef(function Link(
7676
);
7777
});
7878

79+
/**
80+
* A box used to contain a link overlay.
81+
* It is used to create a clickable area that can contain other elements.
82+
*/
7983
export const LinkBox = React.forwardRef(function LinkBox(
8084
props: React.BaseHTMLAttributes<HTMLDivElement>,
8185
ref: React.Ref<HTMLDivElement>
@@ -88,6 +92,11 @@ export const LinkBox = React.forwardRef(function LinkBox(
8892
);
8993
});
9094

95+
/**
96+
* A link overlay that can be used to create a clickable area on top of other elements.
97+
* It is used to create a link that covers the entire area of the element without encapsulating it in a link tag.
98+
* This is useful to avoid nesting links inside links.
99+
*/
91100
export const LinkOverlay = React.forwardRef(function LinkOverlay(
92101
props: LinkProps,
93102
ref: React.Ref<HTMLAnchorElement>

0 commit comments

Comments
 (0)