* adjust flatlist perf settings * calculate initial num to render based on screen height * adjust window size * don't react to screen height changes
11 lines
344 B
TypeScript
11 lines
344 B
TypeScript
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])
|
|
}
|