diff --git a/packages/react-router/src/link.tsx b/packages/react-router/src/link.tsx index e0f4aad84b..5639fed90e 100644 --- a/packages/react-router/src/link.tsx +++ b/packages/react-router/src/link.tsx @@ -614,9 +614,6 @@ export function useLinkProps< // null for LinkUtils const type: 'internal' | 'external' = React.useMemo(() => { - if (rest.reloadDocument) { - return 'external' - } try { new URL(`${to}`) return 'external' diff --git a/packages/react-router/tests/link.test.tsx b/packages/react-router/tests/link.test.tsx index e76cf82c72..f73ee5dfc3 100644 --- a/packages/react-router/tests/link.test.tsx +++ b/packages/react-router/tests/link.test.tsx @@ -1194,68 +1194,77 @@ describe('Link', () => { expect(notFoundComponent).not.toBeCalled() }) - test('when navigating to /posts with params', async () => { - const rootRoute = createRootRoute() - const indexRoute = createRoute({ - getParentRoute: () => rootRoute, - path: '/', - component: () => { + test.each([{ reloadDocument: true }, { reloadDocument: false }])( + 'when navigating to /posts with params', + async ({ reloadDocument }) => { + const rootRoute = createRootRoute() + const indexRoute = createRoute({ + getParentRoute: () => rootRoute, + path: '/', + component: () => { + return ( + <> +

Index

+ + To first post + + + ) + }, + }) + + const PostsComponent = () => { return ( <> -

Index

- - To first post - +

Posts

+ Index + ) - }, - }) - - const PostsComponent = () => { - return ( - <> -

Posts

- Index - - - ) - } + } - const postsRoute = createRoute({ - getParentRoute: () => rootRoute, - path: 'posts', - component: PostsComponent, - }) + const postsRoute = createRoute({ + getParentRoute: () => rootRoute, + path: 'posts', + component: PostsComponent, + }) - const PostComponent = () => { - const params = useParams({ strict: false }) - return Params: {params.postId} - } + const PostComponent = () => { + const params = useParams({ strict: false }) + return Params: {params.postId} + } - const postRoute = createRoute({ - getParentRoute: () => postsRoute, - path: '$postId', - component: PostComponent, - }) + const postRoute = createRoute({ + getParentRoute: () => postsRoute, + path: '$postId', + component: PostComponent, + }) - const router = createRouter({ - routeTree: rootRoute.addChildren([ - indexRoute, - postsRoute.addChildren([postRoute]), - ]), - }) + const router = createRouter({ + routeTree: rootRoute.addChildren([ + indexRoute, + postsRoute.addChildren([postRoute]), + ]), + }) - render() + render() - const postLink = await screen.findByRole('link', { name: 'To first post' }) + const postLink = await screen.findByRole('link', { + name: 'To first post', + }) - expect(postLink).toHaveAttribute('href', '/posts/id1') + expect(postLink).toHaveAttribute('href', '/posts/id1') - fireEvent.click(postLink) + fireEvent.click(postLink) - const paramText = await screen.findByText('Params: id1') - expect(paramText).toBeInTheDocument() - }) + const paramText = await screen.findByText('Params: id1') + expect(paramText).toBeInTheDocument() + }, + ) test('when navigating from /posts to ./$postId', async () => { const rootRoute = createRootRoute()