Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

refactor: memoize functional components in PostHeader, QuotedPost, FallbackAccountName, NumberedStat, and Slug for improved performance

yoginth.com 1db1a1f1 db5a0ec9

verified
+10 -5
+2 -1
apps/web/src/components/Post/PostHeader.tsx
··· 5 5 PostGroupInfoFragment, 6 6 TimelineItemFragment 7 7 } from "@hey/indexer"; 8 + import { memo } from "react"; 8 9 import PostMenu from "@/components/Post/Actions/Menu"; 9 10 import stopEventPropagation from "@/helpers/stopEventPropagation"; 10 11 import { usePostStore } from "@/store/non-persisted/post/usePostStore"; ··· 60 61 ); 61 62 }; 62 63 63 - export default PostHeader; 64 + export default memo(PostHeader);
+2 -1
apps/web/src/components/Post/QuotedPost.tsx
··· 1 1 import type { PostFragment } from "@hey/indexer"; 2 + import { memo } from "react"; 2 3 import PostWarning from "@/components/Shared/Post/PostWarning"; 3 4 import PostWrapper from "@/components/Shared/Post/PostWrapper"; 4 5 import { ··· 45 46 ); 46 47 }; 47 48 48 - export default QuotedPost; 49 + export default memo(QuotedPost);
+2 -1
apps/web/src/components/Shared/FallbackAccountName.tsx
··· 1 1 import getAccount from "@hey/helpers/getAccount"; 2 2 import type { AccountFragment } from "@hey/indexer"; 3 3 import type { ReactNode } from "react"; 4 + import { memo } from "react"; 4 5 import AccountLink from "@/components/Shared/Account/AccountLink"; 5 6 import cn from "@/helpers/cn"; 6 7 import Slug from "./Slug"; ··· 42 43 ); 43 44 }; 44 45 45 - export default FallbackAccountName; 46 + export default memo(FallbackAccountName);
+2 -1
apps/web/src/components/Shared/NumberedStat.tsx
··· 1 1 import type { ReactNode } from "react"; 2 + import { memo } from "react"; 2 3 import humanize from "@/helpers/humanize"; 3 4 import { Card, H4 } from "./UI"; 4 5 ··· 19 20 ); 20 21 }; 21 22 22 - export default NumberedStat; 23 + export default memo(NumberedStat);
+2 -1
apps/web/src/components/Shared/Slug.tsx
··· 1 + import { memo } from "react"; 1 2 import cn from "@/helpers/cn"; 2 3 3 4 interface SlugProps { ··· 26 27 ); 27 28 }; 28 29 29 - export default Slug; 30 + export default memo(Slug);