File tree 1 file changed +18
-6
lines changed
1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,15 @@ const CommentDate = styled.Text`
49
49
// `;
50
50
51
51
class GistCommentsScreen extends React . Component {
52
- state = {
53
- comment : '' ,
52
+ constructor ( ) {
53
+ super ( ) ;
54
+ this . state = {
55
+ comment : '' ,
56
+ } ;
57
+ this . timeout = null ;
54
58
}
55
59
componentDidMount ( ) {
56
- this . props . fetchComments ( this . props . navigation . getParam ( 'gistData' ) . id ) ;
60
+ this . fetchComments ( ) ;
57
61
}
58
62
59
63
// onEndReachedThreshold = () => {
@@ -70,10 +74,18 @@ class GistCommentsScreen extends React.Component {
70
74
. then ( ( ) => {
71
75
this . setState ( { comment : '' } ) ;
72
76
this . props . fetchComments ( this . props . navigation . getParam ( 'gistData' ) . id ) ;
73
- // .then(() => {})
74
- // .catch(error => console.log('error---------', error));
75
77
} )
76
- . catch ( error => console . log ( '&&&&&&&&&&&&&&&&&&&&&' , error ) ) ;
78
+ . catch ( console . log ) ;
79
+ }
80
+
81
+ fetchComments = ( ) => {
82
+ this . props . fetchComments ( this . props . navigation . getParam ( 'gistData' ) . id ) ;
83
+ this . registerForDataFetch ( ) ;
84
+ }
85
+
86
+ registerForDataFetch = ( ) => {
87
+ clearTimeout ( this . timeout ) ;
88
+ this . timeout = setTimeout ( this . fetchComments , 20000 ) ;
77
89
}
78
90
79
91
renderItem = ( { item } ) => {
You can’t perform that action at this time.
0 commit comments