react-infinite-scroll-component: does not load the first page if not scrolling down
the next
callback seems to be called only after a scroll down event. if the page isn’t full and I cannot scroll down to the bottom (cause I already reached it), then the loader
is displayed, but the next
callback doesn’t get called. this is obvious when you start the component with no children.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 26
- Comments: 23 (5 by maintainers)
It would be great if this can be fixed!
Set the body to
min-height: 101vh;
did the job for me.Thanks so much. This helps definitely. I’ll see how can I do this in this component. 😃
On Mon, 5 Feb 2018 at 07:08 stevearoonie notifications@github.com wrote:
This is also affecting if the user has bigger screen than the initial data fetch (users can’t scroll down)
This is a serious problem if a user has a large screen that displays more items than you would expect. I don’t want to load two times the amount of items that 95% of my users need just for that, so I did the following in my component with a useEffect hook:
where itemCount is the number of item you want to display. Hope it helps anyone!
Any news on this, I am having the same issue. As @nareshbhatia commented, the best solution I can think of and the more natural is that the next functions should be called on component instantiation.
Thanks
As opposed to the
prefill
solution mentioned above, can we implement a cheap workaround whereby one call tonext()
will be made when the component is instantiated? If the page size is large enough, this gives us the prefill that’s needed. Basically, this workaround avoids setting up a separate mechanism for loading the initial data.Can you help me in giving a reduced example to showcase the problem? AFAIK the library has no way of calling next until the scroll happens and it reaches the bottom. Unless that happens I don’t seem to have trigger which I could listen to.
The assumption is the userland code will make the call for the first fetch of data, and render it, and the height of the content is more than the innerHeight so that a scroll comes and then InfiniteScroll can take over.
Okay, I see. The
next
callback gets triggered only onscroll
events. Is it not possible to call the next function yourself oncomponentDidMount
of your component?