Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass replace param to Link component #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useRouter } from "./router-provider";
export type LinkProps<Params extends RouteParams> = {
to: RouteInstance<Params> | string;
params?: Params;
replace?: boolean;
query?: RouteQuery;
className?: string;
activeClassName?: string;
Expand All @@ -18,7 +19,7 @@ const LinkView = <Params extends RouteParams>(
props: LinkProps<Params>,
ref: ForwardedRef<HTMLAnchorElement>,
) => {
const { to, params, query, activeClassName, inactiveClassName, ...linkProps } = props;
const { to, params, query, activeClassName, inactiveClassName, replace, ...linkProps } = props;
if (typeof props.to === "string") {
return (
<NormalLink ref={ref} href={props.to} {...linkProps} className={clsx(props.className)} />
Expand Down Expand Up @@ -48,6 +49,7 @@ const RouteLinkView = <Params extends RouteParams>(
onClick,
children,
target,
replace,
...linkProps
} = props;

Expand Down Expand Up @@ -97,6 +99,7 @@ const RouteLinkView = <Params extends RouteParams>(
navigate({
params: params || ({} as Params),
query: query || {},
replace,
});
}}
>
Expand Down