Fix `onEndReached` not firing sometimes on web (#4728)
* handle off screen visibility observer. * Revert "handle off screen visibility observer." This reverts commit e499ea0ed66b31964f79261b41f58a288b0cdb6f. * key ftw * Remove special case --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>zio/stable
parent
d837f96478
commit
ca7386967a
|
@ -25,7 +25,6 @@ import {LoadMoreRetryBtn} from '#/view/com/util/LoadMoreRetryBtn'
|
||||||
import {CenteredView} from '#/view/com/util/Views'
|
import {CenteredView} from '#/view/com/util/Views'
|
||||||
import {FeedItem} from './FeedItem'
|
import {FeedItem} from './FeedItem'
|
||||||
import hairlineWidth = StyleSheet.hairlineWidth
|
import hairlineWidth = StyleSheet.hairlineWidth
|
||||||
import {isWeb} from '#/platform/detection'
|
|
||||||
|
|
||||||
const EMPTY_FEED_ITEM = {_reactKey: '__empty__'}
|
const EMPTY_FEED_ITEM = {_reactKey: '__empty__'}
|
||||||
const LOAD_MORE_ERROR_ITEM = {_reactKey: '__load_more_error__'}
|
const LOAD_MORE_ERROR_ITEM = {_reactKey: '__load_more_error__'}
|
||||||
|
@ -183,15 +182,7 @@ export function Feed({
|
||||||
refreshing={isPTRing}
|
refreshing={isPTRing}
|
||||||
onRefresh={onRefresh}
|
onRefresh={onRefresh}
|
||||||
onEndReached={onEndReached}
|
onEndReached={onEndReached}
|
||||||
onEndReachedThreshold={
|
onEndReachedThreshold={2}
|
||||||
/*
|
|
||||||
NOTE:
|
|
||||||
web's intersection observer struggles with the 2x threshold
|
|
||||||
and leads to missed pagination, so we keep it <1
|
|
||||||
-prf
|
|
||||||
*/
|
|
||||||
isWeb ? 0.6 : 2
|
|
||||||
}
|
|
||||||
onScrolledDownChange={onScrolledDownChange}
|
onScrolledDownChange={onScrolledDownChange}
|
||||||
contentContainerStyle={s.contentContainer}
|
contentContainerStyle={s.contentContainer}
|
||||||
// @ts-ignore our .web version only -prf
|
// @ts-ignore our .web version only -prf
|
||||||
|
|
|
@ -365,6 +365,7 @@ function ListImpl<ItemT>(
|
||||||
root={containWeb ? nativeRef : null}
|
root={containWeb ? nativeRef : null}
|
||||||
onVisibleChange={onTailVisibilityChange}
|
onVisibleChange={onTailVisibilityChange}
|
||||||
bottomMargin={(onEndReachedThreshold ?? 0) * 100 + '%'}
|
bottomMargin={(onEndReachedThreshold ?? 0) * 100 + '%'}
|
||||||
|
key={data?.length}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{footerComponent}
|
{footerComponent}
|
||||||
|
|
Loading…
Reference in New Issue