From 3c34f99ffa0bde5bf5589a1cb1243daad0c40296 Mon Sep 17 00:00:00 2001 From: Stefan Probst Date: Wed, 5 Feb 2025 15:10:08 +0100 Subject: [PATCH] fix: avoid duplicating classs in nav-link merge-props --- components/link.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/link.tsx b/components/link.tsx index 3a8956cb..bdfe7939 100644 --- a/components/link.tsx +++ b/components/link.tsx @@ -43,6 +43,9 @@ export const Link = forwardRef(function Link( props: Readonly, forwardedRef: ForwardedRef, ): ReactNode { + /** Ensure `className` is passed to `mergProps` only once to avoid duplication. */ + const { className: _, ...interactionProps } = props; + const ref = useRef(null); const linkRef = useObjectRef( useMemo(() => { @@ -56,9 +59,9 @@ export const Link = forwardRef(function Link( const isLinkElement = Boolean(props.href) && !isDisabled; const ElementType: ElementType = isLinkElement ? LocaleLink : "span"; - const { focusableProps } = useFocusable(props, linkRef); - const { pressProps, isPressed } = usePress({ ...props, ref: linkRef }); - const { hoverProps, isHovered } = useHover(props); + const { focusableProps } = useFocusable(interactionProps, linkRef); + const { pressProps, isPressed } = usePress({ ...interactionProps, ref: linkRef }); + const { hoverProps, isHovered } = useHover(interactionProps); const { focusProps, isFocused, isFocusVisible } = useFocusRing(); const renderProps = useRenderProps({