Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
1import type { AnyPostFragment } from "@hey/indexer";
2import type { ComponentProps, ReactNode } from "react";
3import { memo } from "react";
4import { Link } from "react-router";
5import { usePostLinkStore } from "@/store/non-persisted/navigation/usePostLinkStore";
6
7interface PostLinkProps extends Omit<ComponentProps<typeof Link>, "to"> {
8 post: AnyPostFragment;
9 children: ReactNode;
10}
11
12const PostLink = ({ post, children, onClick, ...props }: PostLinkProps) => {
13 const { setCachedPost } = usePostLinkStore();
14
15 return (
16 <Link
17 to={`/posts/${post.slug}`}
18 {...props}
19 onClick={(e) => {
20 setCachedPost(post);
21 onClick?.(e);
22 }}
23 >
24 {children}
25 </Link>
26 );
27};
28
29export default memo(PostLink);