gpt4 book ai didi

javascript - React Native 在加载数据时不断跳动

转载 作者:行者123 更新时间:2023-12-05 07:02:05 25 4
gpt4 key购买 nike

我遇到了一个有趣的问题。这是预览

enter image description here

<FlatList
ref={ref}
data={data}
getItemLayout={layout}
scrollEventThrottle={100}
keyExtractor={keyExtractor}
ItemSeparatorComponent={separator}
renderItem={renderItem}
removeClippedSubviews={true}
onContentSizeChange={this.setOffsetOfScrollView}
directionalLockEnabled={true}
/>



setOffsetOfScrollView = () => {
if (validator) {
const children = this.props.children as Array<{
props: {
value: string;
};
}>;
const index = children.findIndex(child => child.props.value === this.props.value);
if (index === -1) {
return;
}
this.flatList.scrollToIndex({ animated: true, index });
}
this.setState({ validator: false });
};

有人能看出问题吗?

最佳答案

尝试删除 setState 行,可能是它让屏幕重新呈现闪回!

关于javascript - React Native 在加载数据时不断跳动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63686941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com