Adjust FlatList performance in main feeds (#3134)

* adjust flatlist perf settings

* calculate initial num to render based on screen height

* adjust window size

* don't react to screen height changes
This commit is contained in:
Hailey 2024-03-06 15:33:23 -08:00 committed by GitHub
parent 357b61d0a5
commit 8b0e575f64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,11 @@
import React from 'react'
import {Dimensions} from 'react-native'
const MIN_POST_HEIGHT = 100
export function useInitialNumToRender(minItemHeight: number = MIN_POST_HEIGHT) {
return React.useMemo(() => {
const screenHeight = Dimensions.get('window').height
return Math.ceil(screenHeight / minItemHeight) + 1
}, [minItemHeight])
}