Skip to content

Commit cd42163

Browse files
authored
Merge pull request #330 from evanyeung/newsfeed-fix-connections-example
Update newsfeed connection example to match the tutorial
2 parents b6f9b19 + de9b2d9 commit cd42163

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

newsfeed/src/components/StoryCommentsSection.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,41 @@ import { graphql } from "relay-runtime";
33
import { useFragment } from "react-relay";
44
import type { StoryCommentsSectionFragment$key } from "./__generated__/StoryCommentsSectionFragment.graphql";
55
import Comment from "./Comment";
6-
7-
const { useState, useTransition } = React;
6+
import LoadMoreCommentsButton from "./LoadMoreCommentsButton";
87

98
export type Props = {
109
story: StoryCommentsSectionFragment$key;
1110
};
1211

1312
const StoryCommentsSectionFragment = graphql`
1413
fragment StoryCommentsSectionFragment on Story {
15-
comments(first: 1) {
16-
pageInfo {
17-
startCursor
18-
}
14+
comments(first: 3) {
1915
edges {
2016
node {
2117
id
2218
...CommentFragment
2319
}
2420
}
21+
pageInfo {
22+
hasNextPage
23+
}
2524
}
2625
}
2726
`;
2827

2928
export default function StoryCommentsSection({ story }: Props) {
3029
const data = useFragment(StoryCommentsSectionFragment, story);
30+
const onLoadMore = () => {
31+
/* TODO */
32+
};
3133
return (
3234
<div>
3335
{data.comments.edges.map((edge) => (
3436
<Comment key={edge.node.id} comment={edge.node} />
3537
))}
38+
{data.comments.pageInfo.hasNextPage && (
39+
<LoadMoreCommentsButton onClick={onLoadMore} />
40+
)}
3641
</div>
3742
);
3843
}

newsfeed/src/components/__generated__/StoryCommentsSectionFragment.graphql.ts

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)