Skip to content

Instantly share code, notes, and snippets.

@prabhat1707
Created September 13, 2021 12:00
Show Gist options
  • Save prabhat1707/604f0c9a24f7c6c68e922b3262208792 to your computer and use it in GitHub Desktop.
Save prabhat1707/604f0c9a24f7c6c68e922b3262208792 to your computer and use it in GitHub Desktop.
const renderItem = ({ item }) => (<Text key={item.key}>{item.key}</Text>);
// we set the height of item is fixed
const getItemLayout = (data, index) => (
{length: ITEM_HEIGHT, offset: ITEM_HEIGHT * index, index}
);
const items = [{ key: 'a' }, { key: 'b'}, ...+400];
function render () => (
<FlatList
data={items}
renderItem={renderItem}
getItemLayout={getItemLayout}
initialNumToRender={5}
maxToRenderPerBatch={10}
windowSize={10}
/>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment