ScrollView with stickyHeaderIndices and contentOffset
React Native: 0.14
I can't use stickyHeaderIndices in conjunction with contentOffset, it returns:
Sticky header index 1 was outside the range {0,0}
If I remove one or the other each feature works as expected, but together they just won't.
this issue has been driving me nuts! anyone having any luck?
It seems when there's contentOffset prop, the scroll view will did scroll action before rendering its children nodes, and the scroll action will triggers sticky header method(which maybe should not? ), and causes this out of range error. I think it is a bug needed to be fixed by official team.
But a temporary solution is to change the stickyHeaderIndicies value when the component is mounted, just like this:
// the component
componentDidMount(){
this.setState({stickyHeaderIndices:[0]})
},
getInitialState(){
return {stickyHeaderIndices:[]}
},
// when rendering scrollview props
stickyHeaderIndices={this.state.stickyHeaderIndices}
+1 with @watert It only happens when component have contentOffset property.
I believe this is already fixed in latest master branch.
@facebook-github-bot answered
Closing this issue as @christopherdro says the question asked has been answered. Please help us by asking questions on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.