@@ -4,26 +4,26 @@ import { ThresholdUnits, parseThreshold } from "./utils/threshold";
4
4
5
5
type Fn = ( ) => any ;
6
6
interface Props {
7
- next : Fn ;
8
- hasMore : boolean ;
9
- children : ReactNode ;
7
+ next ? : Fn ;
8
+ hasMore ? : boolean ;
9
+ children ? : ReactNode ;
10
10
loader : ReactNode ;
11
- scrollThreshold : number | string ;
12
- endMessage : ReactNode ;
13
- style : CSSProperties ;
14
- height : number ;
15
- scrollableTarget : ReactNode ;
16
- hasChildren : boolean ;
17
- pullDownToRefresh : boolean ;
18
- pullDownToRefreshContent : ReactNode ;
19
- releaseToRefreshContent : ReactNode ;
20
- pullDownToRefreshThreshold : number ;
21
- refreshFunction : Fn ;
22
- onScroll : ( e : MouseEvent ) => any ;
11
+ scrollThreshold ? : number | string ;
12
+ endMessage ? : ReactNode ;
13
+ style ? : CSSProperties ;
14
+ height ? : number ;
15
+ scrollableTarget ? : ReactNode ;
16
+ hasChildren ? : boolean ;
17
+ pullDownToRefresh ? : boolean ;
18
+ pullDownToRefreshContent ? : ReactNode ;
19
+ releaseToRefreshContent ? : ReactNode ;
20
+ pullDownToRefreshThreshold ? : number ;
21
+ refreshFunction ? : Fn ;
22
+ onScroll ? : ( e : MouseEvent ) => any ;
23
23
dataLength : number ;
24
- initialScrollY : number ;
25
- key : string ;
26
- className : string ;
24
+ initialScrollY ? : number ;
25
+ key ? : string ;
26
+ className ? : string ;
27
27
}
28
28
29
29
interface State {
@@ -191,7 +191,7 @@ export default class InfiniteScroll extends Component<Props, State> {
191
191
// user is scrolling down to up
192
192
if ( this . currentY < this . startY ) return ;
193
193
194
- if ( this . currentY - this . startY >= this . props . pullDownToRefreshThreshold ) {
194
+ if ( this . currentY - this . startY >= Number ( this . props . pullDownToRefreshThreshold ) ) {
195
195
this . setState ( {
196
196
pullToRefreshThresholdBreached : true
197
197
} ) ;
@@ -207,7 +207,7 @@ export default class InfiniteScroll extends Component<Props, State> {
207
207
}
208
208
} ;
209
209
210
- onEnd : EventListener = evt => {
210
+ onEnd : EventListener = ( ) => {
211
211
this . startY = 0 ;
212
212
this . currentY = 0 ;
213
213
@@ -254,7 +254,7 @@ export default class InfiniteScroll extends Component<Props, State> {
254
254
if ( typeof this . props . onScroll === "function" ) {
255
255
// Execute this callback in next tick so that it does not affect the
256
256
// functionality of the library.
257
- setTimeout ( ( ) => this . props . onScroll ( event ) , 0 ) ;
257
+ setTimeout ( ( ) => this . props . onScroll && this . props . onScroll ( event ) , 0 ) ;
258
258
}
259
259
260
260
let target =
@@ -274,7 +274,7 @@ export default class InfiniteScroll extends Component<Props, State> {
274
274
if ( atBottom && this . props . hasMore ) {
275
275
this . actionTriggered = true ;
276
276
this . setState ( { showLoader : true } ) ;
277
- this . props . next ( ) ;
277
+ this . props . next && this . props . next ( ) ;
278
278
}
279
279
280
280
this . lastScrollTop = target . scrollTop ;
0 commit comments