React Native FlatList Item onLayout всегда возвращает y: 0, x: 0 - PullRequest
0 голосов
/ 02 мая 2020

Я хотел бы знать значение y в каждом элементе FlatList, однако оно всегда должно возвращать 0, какой-либо код неправильный? (ScrollView возвращает правильное значение)

function getLayout(event, id) { 
    const { y } = event.nativeEvent.layout;
    console.log("y: " + y + "| id: " + id);
    console.log(event.nativeEvent);    
}

function Item({ id, img }) {
    return (
        <View style={styles.imageBoxContainer} onLayout={(event) => getLayout(event, id)} >
            <Image source={img} />          
        </View>
    );
}  

<FlatList
    data={DATA}
    renderItem={({ item }) => <Item img={item.img} id={item.id}/>}
    keyExtractor={item => item.id}
/>
...