Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useCallback, forwardRef, Ref } from 'react'

import { navigate } from './navigate'
import { navigate, NavigateOptions } from './navigate'
import { useBasePath, useFullPath } from './location'

export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement>, NavigateOptions {
href: string
basePath?: string
children?: React.ReactNode
Expand All @@ -15,7 +15,10 @@ export interface ActiveLinkProps extends LinkProps {
exactActiveClass?: string
}

function Link({ href, basePath, ...props }: LinkProps, ref?: Ref<HTMLAnchorElement>) {
function Link(
{ href, basePath, replace, query, state, ...props }: LinkProps,
ref?: Ref<HTMLAnchorElement>,
) {
basePath = useLinkBasePath(basePath)
href = getLinkHref(href, basePath)

Expand All @@ -31,7 +34,7 @@ function Link({ href, basePath, ...props }: LinkProps, ref?: Ref<HTMLAnchorEleme
}
if (shouldTrap(e, target)) {
e.preventDefault() // prevent the link from actually navigating
navigate(e.currentTarget.href)
navigate(e.currentTarget.href, { replace: replace, query: query, state: state })
}
},
[onClick, target],
Expand Down