Last active
June 16, 2017 13:03
-
-
Save viviancromwell/ab540606af94b2ff858c to your computer and use it in GitHub Desktop.
Infinite list with RN (OnScroll: How to update the renderModel)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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