1- import React from 'react' ;
1+ import React , { Fragment } from 'react' ;
22import { Query } from 'react-apollo' ;
33
44import { GET_COMMENTS_OF_ISSUE } from './queries' ;
@@ -36,7 +36,7 @@ const updateQuery = (previousResult, { fetchMoreResult }) => {
3636 } ;
3737} ;
3838
39- const CommentList = ( { repositoryOwner, repositoryName, issue } ) => (
39+ const Comments = ( { repositoryOwner, repositoryName, issue } ) => (
4040 < Query
4141 query = { GET_COMMENTS_OF_ISSUE }
4242 variables = { {
@@ -58,33 +58,51 @@ const CommentList = ({ repositoryOwner, repositoryName, issue }) => (
5858 }
5959
6060 return (
61- < div className = "CommentList" >
62- { repository . issue . comments . edges . map ( ( { node } ) => (
63- < CommentItem key = { node . id } comment = { node } />
64- ) ) }
65-
66- < FetchMore
61+ < Fragment >
62+ < CommentList
63+ comments = { repository . issue . comments }
6764 loading = { loading }
68- hasNextPage = {
69- repository . issue . comments . pageInfo . hasNextPage
70- }
71- variables = { {
72- cursor : repository . issue . comments . pageInfo . endCursor ,
73- repositoryOwner,
74- repositoryName,
75- number : issue . number ,
76- } }
77- updateQuery = { updateQuery }
65+ number = { issue . number }
66+ repositoryOwner = { repositoryOwner }
67+ repositoryName = { repositoryName }
7868 fetchMore = { fetchMore }
79- >
80- Comments
81- </ FetchMore >
69+ />
8270
8371 < CommentAdd issueId = { repository . issue . id } />
84- </ div >
72+ </ Fragment >
8573 ) ;
8674 } }
8775 </ Query >
8876) ;
8977
90- export default CommentList ;
78+ const CommentList = ( {
79+ comments,
80+ loading,
81+ repositoryOwner,
82+ repositoryName,
83+ number,
84+ fetchMore,
85+ } ) => (
86+ < div className = "CommentList" >
87+ { comments . edges . map ( ( { node } ) => (
88+ < CommentItem key = { node . id } comment = { node } />
89+ ) ) }
90+
91+ < FetchMore
92+ loading = { loading }
93+ hasNextPage = { comments . pageInfo . hasNextPage }
94+ variables = { {
95+ cursor : comments . pageInfo . endCursor ,
96+ repositoryOwner,
97+ repositoryName,
98+ number,
99+ } }
100+ updateQuery = { updateQuery }
101+ fetchMore = { fetchMore }
102+ >
103+ Comments
104+ </ FetchMore >
105+ </ div >
106+ ) ;
107+
108+ export default Comments ;
0 commit comments