react-native-sortable-list
react-native-sortable-list copied to clipboard
Using order? prop to initial rows order
I have a warning message as using order prop in sortable list
<SortableList
style={styleSheet.btn_container_content_skill}
scrollEnabled={false}
contentContainerStyle={styles.contentContainer}
data={data}
order={['0','2','1','3','4']}
sortingEnabled={this.state.sortableFlag}
onChangeOrder={this._onChangeOrder}
renderRow={this._renderRow} />
Data to show :
const data = {
0: {
text: '0 : One such example is a solar panel which could charge an LED lamp to create hours of light each day',
},
1: {
text: '1 : In addition to being fairly costly, these create smoke pollution and carbon emissions',
},
2: {
text: '2 : Therefore, alternatives are being investigated',
},
3: {
text: '3 : A result of not being connected to the electricity grid in rural areas of some countries means people light their homes using kerosene lamps',
},
4: {
text: '4 : However, most of these workers would not consider career alternatives',
}
};
I want to update the order of data when pressing button, does anyone have the solution to resolve it? Thank you.
I think you could/should pass a unique key down to a ListView or SectionList when rendering a list. It will improve rendering! FlatList/ListView/SectionList all use keyExtractor
to get the job done FlatList