我有一个数据源数组,其中包含多种类型的组,例如“我管理的组”、“我所属的组”和“最喜欢的组”。默认情况下,SectionList 在最后显示“收藏夹组”部分,但我想首先显示它。我该怎么做?请帮忙。
我的代码:
<SectionList
renderItem={({ index, section }) =>
this._renderGroups(section.data[index], section.title, index)
}
stickySectionHeadersEnabled={true}
renderSectionHeader={({ section: { title } }) => (
<View style={styles.headerTiltle}>
<Text
style={{
...CommonStyles.Header1Style(20)
}}
>
{this.state.appString[title]}
</Text>
</View>
)}
sections={this.state.dataSource}
// sections={[{ data: this.state.dataSource, index:2 }, { data: this.state.dataSource, index:0 }, {data: this.state.dataSource, index:1}]}
// sections={[
// {title: "Favourite Groups", data: this.state.dataSource},
// {title: "Groups I Manage", data: this.state.dataSource},
// {title: "Groups I Belong To", data: this.state.dataSource}
// ]}
keyExtractor={(item, index) => item + index}
/>