react-native-masonry-list icon indicating copy to clipboard operation
react-native-masonry-list copied to clipboard

onEndReached not getting called

Open moinqureshi-ss opened this issue 2 years ago • 13 comments

when there is not enough content to cover the whole screen then onEndReached is not getting fired unlike flatlist where onEndReached gets called if content is not covering whole screen. onEndReached gets fired only after user scrolls. i tried passing onEndReachedThreshold also.

To Reproduce keep content small that does not cover whole screen on first page of pagination

Expected behavior onEndReached should get fired even if content is not covering whole screen

Smartphone (please complete the following information): both android and iOS

moinqureshi-ss avatar Aug 30 '22 12:08 moinqureshi-ss

Can you please check if your issue is solved by using this fix. https://github.com/hyochan/react-native-masonry-list/pull/46#issue-1361543895

Vin-Xi avatar Sep 05 '22 07:09 Vin-Xi

@Vin-Xi sadly it did not work. my issue is not when it is very close to end. my issue occurs when we have only enough content to fill like half of the screen. in this case flatlist would still fire onEndReached but here it is not happening

moinqureshi-ss avatar Sep 06 '22 04:09 moinqureshi-ss

Could you kindly share a reproducible example or contribute to our example project for the reproduction?

hyochan avatar Sep 29 '22 05:09 hyochan

@hyochan i have created this https://snack.expo.dev/4DEtapwyv expo snack where i have added both flatlist and masonryList(this is commented). when you run, it will fire onEndReached and show alert for flatlist but when you try masonryList code it will not fire onEndReached

moinqureshi-ss avatar Sep 30 '22 11:09 moinqureshi-ss

I am confused if this is actually needed.

Looking into the issue https://github.com/facebook/react-native/issues/16067, it looks like this isn't expected. What do you think about the issue above @moinqureshi-ss ?

hyochan avatar Sep 30 '22 17:09 hyochan

yeah onEndReached should not be called when flatlist is rendered what i generally do is use isLoading flag inside onEndReached so it fires the api only if !isLoading. currently for masonry-list onEndReached is fired only when content is very close to the screen end, so if let say i am doing pagination for an api with 4 items per page api fires first time but those 4 item don't cover the whole screen it cover only half screen then to fire the api for second page i have to scroll only after that onEndReached is fired.

moinqureshi-ss avatar Oct 03 '22 05:10 moinqureshi-ss

yeah onEndReached should not be called when flatlist is rendered what i generally do is use isLoading flag inside onEndReached so it fires the api only if !isLoading. currently for masonry-list onEndReached is fired only when content is very close to the screen end, so if let say i am doing pagination for an api with 4 items per page api fires first time but those 4 item don't cover the whole screen it cover only half screen then to fire the api for second page i have to scroll only after that onEndReached is fired.

So you want to load the API again after the 4 items and the MasonryList is not closeToBottom. What if you check it conditionally to fetch once again if the sum of visible items' heights is smaller than the MasonryList height?

I am not sure if this feature should be included in MasonryList by the way.

hyochan avatar Oct 09 '22 11:10 hyochan

@hyochan onEndReached is not called at all in any condition. Please check.

satyam16998 avatar Jan 24 '23 10:01 satyam16998

@satyam16998 Could you kindly try the example project and check out the symptoms? The last time I tested on example, it worked well.

hyochan avatar Jan 24 '23 10:01 hyochan

@hyochan I have tried and it's not working. Earlier it was working.

I guess when we have data on which masonry list is acting like a flat list then the onEndReached is not working properly in this case. Please have a look.Thanks!

satyam16998 avatar Jan 24 '23 10:01 satyam16998

@satyam16998 What do you mean by you have data on which masonry list is acting like a flat list? Also, I've just tested this in the MasonryExample project, which is working as expected. Please check the below clip.

https://user-images.githubusercontent.com/27461460/214312229-62a3b1d5-9cb5-444e-8bbc-c1befafee3b9.mov

hyochan avatar Jan 24 '23 13:01 hyochan

@hyochan I mean when we have the same height of both columns then onEndReached is not called. For example, just take a single object and repeat the same object multiple times in an array and then check.

satyam16998 avatar Jan 25 '23 05:01 satyam16998

@hyochan I mean when we have the same height of both columns then onEndReached is not called. For example, just take a single object and repeat the same object multiple times in an array and then check.

@hyochan ??

satyam16998 avatar Jan 27 '23 07:01 satyam16998