I'm following this tutorial https://medium.com/appandflow/react-native-collapsible-navbar-e51a049b560a to create a navbar collapsed. Work's fine, but there's a problem, in this tutorial the autor set the props onscroll of the FlatList:
onScroll={Animated.event( [{ nativeEvent: { contentOffset: { y: this.state.scrollAnim } } }], { useNativeDriver: true },)}
But i already using this onScroll Props for:
onScroll={event => this.handleScroll(event)}
My handle scroll will verify if is the end of the scroll and load more feed:
handleScroll (event) {
var endOfPage = event.nativeEvent.layoutMeasurement.height + event.nativeEvent.contentOffset.y >=
event.nativeEvent.contentSize.height;
if (endOfPage) {
this.getSections()
}
}
I cant running my function and the autor command in the same time. Is there a way to execute this two OnScroll?
My componenet AnimatedFlatList (The first OnScroll
will not work because the other will override the last):
<AnimatedFlatList
contentContainerStyle={[collapse.contentContainer, {paddingTop: this.props.navigation.state.params.category == '' ? 166.5 : 96.5}]}
onMomentumScrollBegin={this._onMomentumScrollBegin}
onMomentumScrollEnd={this._onMomentumScrollEnd}
onScroll={event => this.handleScroll(event)}
onScrollEndDrag={this._onScrollEndDrag}
data={this.state.sections}
renderItem={this._renderSectionItem}
extraData={this.state}
keyExtractor={(item, index) => index.toString()}
removeClippedSubviews
onScroll={Animated.event( [{ nativeEvent: { contentOffset: { y: this.state.scrollAnim } } }], { useNativeDriver: true },)}
/>