admin管理员组文章数量:1435859
I'm using to render multiple sections with a different section header. I'm having some trouble to display it the way I want. I would like to have my header at the top and under it, items of the section as a grid.
This is what I have right now
With this code:
<SectionList
contentContainerStyle={styles.sectionListContainer}
renderItem={this.renderItem}
keyExtractor={this.getKey}
renderSectionHeader={this.renderSectionHeader}
shouldItemUpdate={this.shouldItemUpdate}
sections={[
{ data: mostViewedArray, key: "most_viewed", title: "Most viewed" },
{ data: recentlyArray, key: "recently", title: "Recently" }
]}
/>
const styles = StyleSheet.create({
sectionListContainer: {
flex: 1,
flexDirection: "row",
flexWrap: "wrap",
justifyContent: "space-between"
}
});
So I'd like to be able to not apply the css of sectionListContainer to sectionHeader. But I'm not sure it is possible.
If anyone has any idea about it, let me know!
Thanks!
I'm using to render multiple sections with a different section header. I'm having some trouble to display it the way I want. I would like to have my header at the top and under it, items of the section as a grid.
This is what I have right now
With this code:
<SectionList
contentContainerStyle={styles.sectionListContainer}
renderItem={this.renderItem}
keyExtractor={this.getKey}
renderSectionHeader={this.renderSectionHeader}
shouldItemUpdate={this.shouldItemUpdate}
sections={[
{ data: mostViewedArray, key: "most_viewed", title: "Most viewed" },
{ data: recentlyArray, key: "recently", title: "Recently" }
]}
/>
const styles = StyleSheet.create({
sectionListContainer: {
flex: 1,
flexDirection: "row",
flexWrap: "wrap",
justifyContent: "space-between"
}
});
So I'd like to be able to not apply the css of sectionListContainer to sectionHeader. But I'm not sure it is possible.
If anyone has any idea about it, let me know!
Thanks!
Share Improve this question asked Apr 11, 2017 at 16:06 iDamsiDams 1412 silver badges4 bronze badges 1-
1
Could you post the contents of
renderSectionHeader
? Is there some problem with using separate style definitions for the headers and the items as is done here? From the posted code, it appears you are not doing that. – NiFi Commented Apr 11, 2017 at 22:36
1 Answer
Reset to default 2A solution that worked for us, was to force the renderSectionHeader to have the width of the entire container, thereby forcing the render items to the next row.
If you update your question to include the content of renderSectionHeader (as already asked by NiFi), I could provide a more detailed answer on how you would update renderSectionHeader.
本文标签: javascriptReact native SectionList layoutStack Overflow
版权声明:本文标题:javascript - React native SectionList layout - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745675113a2669803.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论