Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onEndReached called on initial render #937

Closed
Samide47 opened this issue Oct 23, 2023 · 14 comments
Closed

onEndReached called on initial render #937

Samide47 opened this issue Oct 23, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@Samide47
Copy link

Current behavior

<FlashList
data={products}
keyExtractor={(item) => item._id}
estimatedItemSize={200}
numColumns={2}
showsVerticalScrollIndicator={false}
renderItem={(item) => (

)}
ListEmptyComponent={}
onEndReached={() => {
console.log("on end reach");
handleStartLoadingMore() && loadMore();
}}
onEndReachedThreshold={0.25}
ListFooterComponent={isLoading && loading more...}
/>

Platform:

  • [ x] iOS
  • [ x] Android

Environment

"@shopify/flash-list": "^1.6.2",
"react": "18.2.0",
"react-native": "0.72.5",

@Samide47 Samide47 added the bug Something isn't working label Oct 23, 2023
@elencho
Copy link

elencho commented Nov 1, 2023

+1

3 similar comments
@jianxinzhoutiti
Copy link

+1

@derrysukrie
Copy link

+1

@csillaj
Copy link

csillaj commented Jan 26, 2024

+1

@zavbala
Copy link

zavbala commented Feb 9, 2024

Yeah, run twice

@LabLamb
Copy link

LabLamb commented Mar 2, 2024

Mine ran non-stop

@naqvitalha
Copy link
Collaborator

If the content doesn't fill the screen on initial render then the callback will fire. If it's being called incorrectly then most like the estimatedItemSize value is incorrect.

@natemartins
Copy link

If the content doesn't fill the screen on initial render then the callback will fire. If it's being called incorrectly then most like the estimatedItemSize value is incorrect.

This issue persists. In my case, the content fills the screen on initial render. Note that I have a list over 30 items.

@purplereborn
Copy link

const [onEnd, setOnEnd] = useState<boolean>(true);

onMomentumScrollBegin={() => setOnEnd(false)}
onEndReached={() => {
          if (!onEnd) {
            onEndReached();
          }
 }}

@jothamc
Copy link

jothamc commented Sep 26, 2024

Following the guidelines on estimatedItemSize helped. I had initially thought it meant how many items would be displayed on each render, but fixing it appropriately solved the problem.

If the content doesn't fill the screen on initial render then the callback will fire. If it's being called incorrectly then most like the estimatedItemSize value is incorrect.

@natemartins
Copy link

Following the guidelines on estimatedItemSize helped. I had initially thought it meant how many items would be displayed on each render, but fixing it appropriately solved the problem.

If the content doesn't fill the screen on initial render then the callback will fire. If it's being called incorrectly then most like the estimatedItemSize value is incorrect.

@jothamc Could you explain further what exactly helped you? Thanks

@Apurba-Kumar-Ghosh
Copy link

@naqvitalha I have added a correct estimatedItemSize and also checks are there for data not to be empty but still onEndReached is called on render before end of list is reached.
Has anyone found a workaround for this?

@jothamc
Copy link

jothamc commented Jan 22, 2025

Following the guidelines on estimatedItemSize helped. I had initially thought it meant how many items would be displayed on each render, but fixing it appropriately solved the problem.

If the content doesn't fill the screen on initial render then the callback will fire. If it's being called incorrectly then most like the estimatedItemSize value is incorrect.

@jothamc Could you explain further what exactly helped you? Thanks

I had thought that estimatedItemSize was the amount of items in a list (I'm not sure why I thought that, maybe the name of the prop), but when I read properly that it's meant to be the value of the height of one item, it helped me calculate the right value for my app.

@jothamc
Copy link

jothamc commented Jan 23, 2025

@naqvitalha I have added a correct estimatedItemSize and also checks are there for data not to be empty but still onEndReached is called on render before end of list is reached. Has anyone found a workaround for this?

Does the above help too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests