Я создаю шпионскую прокрутку для списка разделов и хочу получить значения Y заголовка списка разделов,
Я пытался использовать метод onLayout, но получаю только значение y, равное 0.
Я предполагаю, что мой компонент находится в собственном контейнере, поэтому мое представление получает 0 для этого контейнера.
это мой код:
<Animated.SectionList
initialNumToRender={5}
keyExtractor={(item) => item.docRef}
sections={data.slice()}
renderSectionHeader={this.renderSectionHeader}
renderItem={this.renderItem}
stickySectionHeadersEnabled={false}
/>
renderSectionHeader = ({section}) => {
const index = section.sort;
return (
<View onLayout={e => this.onSectionLayout(e, index)}>
<SectionListHeader section={section} index={index}/>
</View>
)
};
onSectionLayout = ({nativeEvent: {layout: {x, y, width, height}}}, index) =>
{
console.log(height)
};