Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
1import getAccount from "@hey/helpers/getAccount";
2import type { AccountFragment } from "@hey/indexer";
3import type { ComponentProps, ReactNode } from "react";
4import { Link } from "react-router";
5import { useAccountLinkStore } from "@/store/non-persisted/navigation/useAccountLinkStore";
6
7interface AccountLinkProps extends Omit<ComponentProps<typeof Link>, "to"> {
8 account: AccountFragment;
9 children: ReactNode;
10}
11
12const AccountLink = ({
13 account,
14 children,
15 onClick,
16 ...props
17}: AccountLinkProps) => {
18 const { setCachedAccount } = useAccountLinkStore();
19 const { link } = getAccount(account);
20
21 return (
22 <Link
23 to={link}
24 {...props}
25 onClick={(e) => {
26 setCachedAccount(account);
27 onClick?.(e);
28 }}
29 >
30 {children}
31 </Link>
32 );
33};
34
35export default AccountLink;