perf(components): memoize post menus with minimal props

This commit is contained in:
plebeius
2025-12-05 17:38:17 +01:00
parent 5eceba0134
commit 698df59f19
6 changed files with 79 additions and 38 deletions
+33
View File
@@ -0,0 +1,33 @@
import { Comment } from '@plebbit/plebbit-react-hooks';
export type PostMenuProps = {
cid?: string;
postCid?: string;
parentCid?: string;
subplebbitAddress?: string;
isDescription?: boolean;
isRules?: boolean;
authorAddress?: string;
link?: string;
linkWidth?: number;
linkHeight?: number;
thumbnailUrl?: string;
deleted?: boolean;
removed?: boolean;
};
export const selectPostMenuProps = (post?: Comment): PostMenuProps => ({
cid: post?.cid,
postCid: post?.postCid,
parentCid: post?.parentCid,
subplebbitAddress: post?.subplebbitAddress,
isDescription: post?.isDescription,
isRules: post?.isRules,
authorAddress: post?.author?.address,
link: post?.link,
linkWidth: post?.linkWidth,
linkHeight: post?.linkHeight,
thumbnailUrl: post?.thumbnailUrl,
deleted: post?.deleted,
removed: post?.removed,
});