Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Infinite list with RN (OnScroll: How to update the renderModel)
onScroll(e) {
this.updateRenderModel(e.nativeEvent.contentOffset);
}
render() {
var items = this.state.renderModel.map(renderItem => {
const itemStyle = {
position : 'absolute',
height : ITEM_SIZE,
left : 0,
top : renderItem.position,
};
return <View key={renderItem.key} style={itemStyle}><Text style={styles.item}>{renderItem.data}</Text></View>;
});
return (
<View style={styles.container}>
<ScrollView ref="scrollView" style={{flex: 1}} scrollEventThrottle={1} onScroll={this.onScroll.bind(this)}>
<View style={{height: this.state.bodyHeight, width: 480}}>
{items}
</View>
</ScrollView>
</View>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment