I sometimes get the following redbox:
Sticky header index 0 was outside the range {0, 0}
Debugging brought me to ScrollView.m to the following line:
if (idx >= subviewCount) {
RCTLogError(@"Sticky header index %zd was outside the range {0, %zd}", idx, subviewCount);
return;
}
For me it helped to change it to
if (idx > subviewCount) {
Although I havent tried to understand the entire function up to now, the error message "Sticky header index %zd was outside the range {0, %zd}" seems to suggest that it has to be ">" instead of ">=", at least for my case where idx is 0 and subviewCount is 0 as well.
If there are N subviews the indices should be in [0, N-1] so the original check seems right to me. There could certainly be a bug in another place though, possibly in ListView or your renderRow implementation.
@ide OK, can you gimme an example of what I could do wrong in the renderRow implementation that would result in something like that? Why I was assuming a bug here is that the error message says "was outside the range {0, ..}", which is not true, as idx was actually 0. So at least the error message does not fit to the if-statement, does it?
Sometimes if renderRow (or the other render methods) throw an error, you end up getting a native error about the sticky headers instead.
@ide That was exactly the issue for me. One of the render components was trying to read nested data, that didn't exist, from an empty object. Thanks
had the same problem fixed by setting style {flex: 1} for container in which was my listView
Is what Ide mentioned considered an open bug and being tracked anywhere? It's slowly driving me nuts that ListView errors are so hard to track down.
For me it is the DatePickerIOS which is causing this issue. I kind of hate DatePickerIOS right now.
This error took place when I was working on renderSectionHeader of ListView, and I found that it looks for <View>component but not something vague. For example, I have to finish the whole "_if else_" statement instead of use "if" only. Wish my comment help.
Most helpful comment
For me it is the DatePickerIOS which is causing this issue. I kind of hate DatePickerIOS right now.