seatgeek / react-infinite

A browser-ready efficient scrolling container based on UITableView
Other
2.71k stars 275 forks source link

onInfiniteLoad is not invoked when numberOfChildren is 0 #274

Closed ahmehri closed 6 years ago

ahmehri commented 6 years ago

https://github.com/seatgeek/react-infinite/blob/28adb88abd5a8c3aa05de7dba030e3e2f102d725/src/react-infinite.jsx#L284

In my case, the above condition will evaluates to false which will prevent the invocation of onInfiniteLoad. This happens because this.state.numberOfChildren and prevState.numberOfChildren both evaluates to 0 and it makes sense in my use case, but what doesn't is that onInfiniteLoad is not invoked.

I tried to solve this the following way:

    var hasLoadedMoreChildren = this.state.numberOfChildren == 0 && prevState.numberOfChildren === 0
      || this.state.numberOfChildren !== prevState.numberOfChildren;

but I got an Uncaught RangeError: Maximum call stack size exceeded error.

Any idea on how to solve this issue?

ahmehri commented 6 years ago

This is a duplicate of #273. I ended up invoking onInfiniteLoad manually in this edge case as suggested, but this still a workaround and an appropriate fix should be implemented IMHO.

geminiyellow commented 6 years ago

hi @ahmehri , how do you invoking onInfiniteLoad manually in this edge case ?