Skip to content

Commit

Permalink
Revert "Only attach ref when prefetch=viewport is specified"
Browse files Browse the repository at this point in the history
This reverts commit 44f28f3.
  • Loading branch information
brophdawg11 committed Jun 15, 2023
1 parent 219057f commit 748d6a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ interface PrefetchHandlers {
function usePrefetchBehavior<T extends HTMLAnchorElement>(
prefetch: PrefetchBehavior,
theirElementProps: PrefetchHandlers
): [boolean, React.RefObject<T> | null, Required<PrefetchHandlers>] {
): [boolean, React.RefObject<T>, Required<PrefetchHandlers>] {
let [maybePrefetch, setMaybePrefetch] = React.useState(false);
let [shouldPrefetch, setShouldPrefetch] = React.useState(false);
let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } =
Expand Down Expand Up @@ -276,7 +276,7 @@ function usePrefetchBehavior<T extends HTMLAnchorElement>(

return [
shouldPrefetch,
prefetch === "viewport" ? ref : null,
ref,
{
onFocus: composeEventHandlers(onFocus, setIntent),
onBlur: composeEventHandlers(onBlur, cancelIntent),
Expand Down Expand Up @@ -309,7 +309,7 @@ let NavLink = React.forwardRef<HTMLAnchorElement, RemixNavLinkProps>(
<RouterNavLink
{...props}
{...prefetchHandlers}
ref={ref ? mergeRefs(forwardedRef, ref) : forwardedRef}
ref={mergeRefs(forwardedRef, ref)}
to={to}
/>
{shouldPrefetch && !isAbsolute ? (
Expand Down Expand Up @@ -343,7 +343,7 @@ let Link = React.forwardRef<HTMLAnchorElement, RemixLinkProps>(
<RouterLink
{...props}
{...prefetchHandlers}
ref={ref ? mergeRefs(forwardedRef, ref) : forwardedRef}
ref={mergeRefs(forwardedRef, ref)}
to={to}
/>
{shouldPrefetch && !isAbsolute ? (
Expand Down

0 comments on commit 748d6a0

Please sign in to comment.