I am implementing a SectionList showing a list of weeks which needs to scroll to the current week, thus I am using initialScrollIndex.
The problem I face is that I don't really understand what the index given to my _getItemLayout is?
Sometimes data[index] === undefined, which doesn't make sense to me.
I need to know which section it is (data[?]) as each section contains another SectionList for the events that week, thus height isn't a constant.
_getItemLayout = (data, index) => {
const rows = (data[index] === undefined) ? 1 : data[index].data.reduce((sum, value) => value.data.length + sum, 0);
const height = (rows * 94);
return {
length: height,
offset: height * index,
index
};
}