react-native icon indicating copy to clipboard operation
react-native copied to clipboard

ScrollView with stickyHeaderIndices and contentOffset

Open roine opened this issue 11 years ago • 6 comments

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.

roine avatar Oct 13 '15 13:10 roine

this issue has been driving me nuts! anyone having any luck?

arilitan avatar Jan 20 '16 19:01 arilitan

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}

watert avatar Feb 13 '16 13:02 watert

+1 with @watert It only happens when component have contentOffset property.

sercanov avatar Feb 23 '16 19:02 sercanov

I believe this is already fixed in latest master branch.

nicklockwood avatar Feb 23 '16 23:02 nicklockwood

@facebook-github-bot answered

christopherdro avatar Apr 11 '16 06:04 christopherdro

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.

facebook-github-bot avatar Apr 11 '16 06:04 facebook-github-bot