MCPcopy Create free account
hub / github.com/dailydotdev/apps / WithPostById

Function WithPostById

packages/shared/src/components/post/withPostById.tsx:21–39  ·  view source on GitHub ↗
(props: Props & { post?: Post })

Source from the content-addressed store, hash-verified

19 WrappedComponent: WrappedComponentType<Props, LayoutProps>,
20): WrappedComponentType<Props, LayoutProps> => {
21 const WithPostById = (props: Props & { post?: Post }): ReactElement => {
22 const { post: initialPost } = props;
23
24 const { post: loadedPost } = usePostById({
25 id: initialPost?.id,
26 });
27 const post = loadedPost ?? initialPost;
28
29 if (!post?.id) {
30 return null;
31 }
32
33 // Important to maintain the feed meta if it exists
34 if (!post?.feedMeta && initialPost?.feedMeta) {
35 post.feedMeta = initialPost.feedMeta;
36 }
37
38 return <WrappedComponent {...props} post={post} />;
39 };
40
41 WithPostById.displayName = 'WithPostById';
42

Callers

nothing calls this directly

Calls 1

usePostByIdFunction · 0.90

Tested by

no test coverage detected