From 7341294df6156afdf24ab43e1e27ebba94f265ad Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Wed, 11 Jun 2025 20:12:05 +0300
Subject: Fix using screen names in `Link` (#8473)

* use our router in favour of useLinkBuilder

* test feature using Home header feeds button

* handle non-string params properly
---
 src/components/Link.tsx | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

(limited to 'src/components/Link.tsx')

diff --git a/src/components/Link.tsx b/src/components/Link.tsx
index d73a3db4a..49c9c5235 100644
--- a/src/components/Link.tsx
+++ b/src/components/Link.tsx
@@ -4,7 +4,6 @@ import {sanitizeUrl} from '@braintree/sanitize-url'
 import {
   type LinkProps as RNLinkProps,
   StackActions,
-  useLinkBuilder,
 } from '@react-navigation/native'
 
 import {BSKY_DOWNLOAD_URL} from '#/lib/constants'
@@ -95,20 +94,19 @@ export function useLink({
   shouldProxy?: boolean
 }) {
   const navigation = useNavigationDeduped()
-  const {buildHref} = useLinkBuilder()
   const href = useMemo(() => {
     return typeof to === 'string'
       ? convertBskyAppUrlIfNeeded(sanitizeUrl(to))
       : to.screen
-      ? buildHref(to.screen, to.params)
+      ? router.matchName(to.screen)?.build(to.params)
       : to.href
       ? convertBskyAppUrlIfNeeded(sanitizeUrl(to.href))
       : undefined
-  }, [to, buildHref])
+  }, [to])
 
   if (!href) {
     throw new Error(
-      'Link `to` prop must be a string or an object with `screen` and `params` properties',
+      'Could not resolve screen. Link `to` prop must be a string or an object with `screen` and `params` properties',
     )
   }
 
-- 
cgit 1.4.1

