简体   繁体   中英

How to style React Native SectionList sections

How can I give the same style for each section, without taking into account the section header?

Sections are generated dinamycally, after getting an array from the API.

I'm looking for something similar to the following image:

在此处输入图像描述

Well, for that people who's looking for the same thing, I've fixed it by styling the first and last child of each section. This means, on the rendererItem={(item, index, section) =>...} , we are able to check if index === section.data.length - 1 , this means it's the last child so apply border bottom radius. If index === 0 , this means it's the first child of every section, so we apply border top radius.

I've seen a related post, but it didn't work for me. Also, in my case, my SectionList data is dynamic, I have so many sections, so using FlatList for every section of my SectionList is not optimized.

Post: Custom section style in sectionList REACT NATIVE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM