(props: Props & { post?: Post })
| 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 |
nothing calls this directly
no test coverage detected