Skip to content

Commit

Permalink
fix(MyLink): apply origin click event when click triggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyi7099 committed Aug 12, 2019
1 parent 0b4a868 commit f035f4b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/antdsite/src/default-theme/components/MyLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,34 @@ const MyLink: React.SFC<any> = ({
children,
to,
prefetch,
onClick,
...rest
}: {
children: React.ReactNode;
to: string;
prefetch: boolean;
onClick: (e: any) => void;
}) => {
let clickMerged = handleLinkClick;

if (onClick) {
clickMerged = (...args) => {
onClick.apply(null, args);
handleLinkClick();
};
}
return (
<PageContext.Consumer>
{({ webConfig: { base, prefetch: globalPrefetch } }) => {
if (!prefetch || !globalPrefetch) {
return (
<RouterLink onClick={handleLinkClick} to={resolvePathWithBase(to, base)} {...rest}>
<RouterLink onClick={clickMerged} to={resolvePathWithBase(to, base)} {...rest}>
{children}
</RouterLink>
);
}
return (
<Link onClick={handleLinkClick} to={to} {...rest}>
<Link onClick={clickMerged} to={to} {...rest}>
{children}
</Link>
);
Expand Down

0 comments on commit f035f4b

Please sign in to comment.