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:
parent
357b61d0a5
commit
8b0e575f64
3 changed files with 19 additions and 0 deletions
11
src/lib/hooks/useInitialNumToRender.ts
Normal file
11
src/lib/hooks/useInitialNumToRender.ts
Normal 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])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue