Search code examples
androidlistviewreact-native

what onEndReachedThreshold really means in react-native


from documentation:

onEndReachedThreshold number

Threshold in pixels (virtual, not physical) for calling onEndReached. so I just wanted to know what it means, is it threshold from the top, or is it threshold from the bottom.

From the top? - if I set a value of onEndReachedThreshold ={10}, is my onEndReached called as soon as I scrolled to 10 pixel, or something else.

From the bottom? - if I set value of onEndReachedThreshold ={listview height -10}, will my onEndReached called as soon as I scrolled to 10 pixel, or something else.


Solution

  • The documentation is always the best way to go:

    onEndReached function
    Called when all rows have been rendered and the list has been scrolled to within onEndReachedThreshold of the bottom. The native scroll event is provided.

    onEndReachedThreshold number
    Threshold in pixels (virtual, not physical) for calling onEndReached.

    So as I see it: if you do onEndReachedThreshold ={10} it calls onEndReached if you scrolled to 10 pixels from the bottom