@@ -4,26 +4,26 @@ import { ThresholdUnits, parseThreshold } from "./utils/threshold";
44
55type Fn = ( ) => any ;
66interface Props {
7- next : Fn ;
8- hasMore : boolean ;
9- children : ReactNode ;
7+ next ? : Fn ;
8+ hasMore ? : boolean ;
9+ children ? : ReactNode ;
1010 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 ;
2323 dataLength : number ;
24- initialScrollY : number ;
25- key : string ;
26- className : string ;
24+ initialScrollY ? : number ;
25+ key ? : string ;
26+ className ? : string ;
2727}
2828
2929interface State {
@@ -191,7 +191,7 @@ export default class InfiniteScroll extends Component<Props, State> {
191191 // user is scrolling down to up
192192 if ( this . currentY < this . startY ) return ;
193193
194- if ( this . currentY - this . startY >= this . props . pullDownToRefreshThreshold ) {
194+ if ( this . currentY - this . startY >= Number ( this . props . pullDownToRefreshThreshold ) ) {
195195 this . setState ( {
196196 pullToRefreshThresholdBreached : true
197197 } ) ;
@@ -207,7 +207,7 @@ export default class InfiniteScroll extends Component<Props, State> {
207207 }
208208 } ;
209209
210- onEnd : EventListener = evt => {
210+ onEnd : EventListener = ( ) => {
211211 this . startY = 0 ;
212212 this . currentY = 0 ;
213213
@@ -254,7 +254,7 @@ export default class InfiniteScroll extends Component<Props, State> {
254254 if ( typeof this . props . onScroll === "function" ) {
255255 // Execute this callback in next tick so that it does not affect the
256256 // functionality of the library.
257- setTimeout ( ( ) => this . props . onScroll ( event ) , 0 ) ;
257+ setTimeout ( ( ) => this . props . onScroll && this . props . onScroll ( event ) , 0 ) ;
258258 }
259259
260260 let target =
@@ -274,7 +274,7 @@ export default class InfiniteScroll extends Component<Props, State> {
274274 if ( atBottom && this . props . hasMore ) {
275275 this . actionTriggered = true ;
276276 this . setState ( { showLoader : true } ) ;
277- this . props . next ( ) ;
277+ this . props . next && this . props . next ( ) ;
278278 }
279279
280280 this . lastScrollTop = target . scrollTop ;
0 commit comments