Skip to content

Commit e67ce85

Browse files
authored
Merge pull request #20 from risen228/fix/skip-navigation-on-prevent-default
[Fix] Skip navigation on prevent default
2 parents 1e43f4c + b9b56d9 commit e67ce85

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/link.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,20 @@ const RouteLinkView = <Params extends RouteParams>(
7373
{...linkProps}
7474
className={clsx(className, isOpened ? activeClassName : inactiveClassName)}
7575
onClick={(evt) => {
76+
if (onClick) {
77+
onClick(evt);
78+
}
79+
80+
// allow user to prevent navigation
81+
if (evt.defaultPrevented) {
82+
return
83+
}
84+
7685
evt.preventDefault();
7786
navigate({
7887
params: params || ({} as Params),
7988
query: query || {},
8089
});
81-
if (onClick) {
82-
onClick(evt);
83-
}
8490
}}
8591
>
8692
{children}

0 commit comments

Comments
 (0)