Ita*_*uby 5 reactjs react-native react-native-flatlist
我在 FlatList 中有不同高度(250 或 150)的项目,当迭代每个项目并附加 FlatList 的 dataSrouce 的状态时,一切都渲染得很好,但如果我想避免“附加”影响并将 dataSrouce 设置为 all一次显示项目,似乎 FlatList 有一个奇怪的错误,项目没有达到正确的高度(按钮上有一个空白区域,项目应该填充它)。
尝试将“ flexGrow:1 ”放在FlatList上,尝试“ initialNumToRender ”属性,尝试修复视图中每个项目的高度。
FlatList 的容器是“flex:1”。
我的公寓列表:
render() {
const _this = this;
const { loading } = this.state;
return (
<Components.ViewContainer>
{this.printTopHeader()}
{loading ? (
<ActivityIndicator size={25} />
) : (
<FlatList
style={{ flex: 1 }}
removeClippedSubviews={true} //tried with and without
data={this.state.posts}
extraData={this.state.posts} //tried with and without
renderItem={({ item }) => (
<HomeCard
post={item}
/>
)}
keyExtractor={(item, index) => item.key}
/>
)}
</Components.ViewContainer>
);
Run Code Online (Sandbox Code Playgroud)
}
组件.ViewContainer:
const ViewContainer = styled.View`
flex:1;
`;
Run Code Online (Sandbox Code Playgroud)
家乡卡:
render() {
const { theme, showActions } = this.props;
const {
imageUrl,
user,
title,
selectedPlace,
textColor,
backgroundColor
} = this.props.post;
return (
<Components.ContainerView>
...
</Components.ContainerView>
);
}
export default withTheme(HomeCard); // styled-components implementation
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2203 次 |
最近记录: |