Last active
December 17, 2020 10:20
-
-
Save velotiotech/de7398930162145016b8ce5e692dc0ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { useFragment } from "react-relay/hooks"; | |
import { graphql } from "react-relay"; | |
import { | |
BlogPostHead_blogPost$key, BlogPostHead_blogPost | |
} from "./__generated__/BlogPostHead_blogPost.graphql"; | |
import { BlogPostAuthor } from "./BlogPostAuthor"; | |
import { BlogPostLikeControls } from "./BlogPostLikeControls"; | |
interface BlogPostHeadProps { | |
blogPost: BlogPostHead_blogPost$key; | |
} | |
export const BlogPostHead = ({ blogPost }: BlogPostHeadProps) => { | |
const blogPostData = useFragment<BlogPostHead_blogPost>( | |
graphql` | |
fragment BlogPostHead_blogPost on BlogPost { | |
title | |
coverImgUrl | |
...BlogPostAuthor_blogPost | |
...BlogPostLikeControls_blogPost | |
} | |
`, | |
blogPost | |
); | |
return ( | |
<div> | |
<img src={blogPostData.coverImgUrl} /> | |
<h1>{blogPostData.title}</h1> | |
<BlogPostAuthor blogPost={blogPostData} /> | |
<BlogPostLikeControls blogPost={blogPostData} /> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment