Javascript 如何更改SectionList节索引的首选项?
我有一个数据源数组,其中包含多种类型的组,如“我管理的组”、“我属于的组”和“最喜欢的组”。默认情况下,SectionList在末尾显示“Favorite Groups”部分,但我希望首先显示它。我该怎么做?请帮忙 我的代码:Javascript 如何更改SectionList节索引的首选项?,javascript,arrays,react-native,react-native-sectionlist,Javascript,Arrays,React Native,React Native Sectionlist,我有一个数据源数组,其中包含多种类型的组,如“我管理的组”、“我属于的组”和“最喜欢的组”。默认情况下,SectionList在末尾显示“Favorite Groups”部分,但我希望首先显示它。我该怎么做?请帮忙 我的代码: <SectionList renderItem={({ index, section }) => this._renderGroups(section.data[index], section
<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}
/>
此._renderGroup(section.data[index],section.title,index)
}
stickySectionHeadersEnabled={true}
renderSectionHeader={({section:{title}}})=>(
{this.state.appString[title]}
)}
节={this.state.dataSource}
//节={[{data:this.state.dataSource,索引:2},{data:this.state.dataSource,索引:0},{data:this.state.dataSource,索引:1}]}
//部分={[
//{title:“收藏夹组”,数据:this.state.dataSource},
//{title:“我管理的组”,数据:this.state.dataSource},
//{title:“我所属的组”,数据:this.state.dataSource}
// ]}
keyExtractor={(项,索引)=>item+index}
/>
我必须更改向最终数组添加数据的顺序
var respArray = [];
if (favouriteGroups.length)
favouriteGroups.map((item) => {
item.s3photo = getSignedUrl( item.photo );
});
respArray.push({
title: 'lbl_favourite_groups',
data: favouriteGroups,
});
if (managed_by.length)
managed_by.map((item) => {
item.s3photo = getSignedUrl( item.photo );
});
respArray.push({
title: 'lbl_groups_i_manage',
data: managed_by,
});
if (belongs_to.length)
belongs_to.map((item) => {
item.s3photo = getSignedUrl( item.photo );
});
respArray.push({
title: 'lbl_groups_i_belongs_to',
data: belongs_to,
});