A
A
ART42020-07-15 18:33:24
React Native
ART4, 2020-07-15 18:33:24

How to make new records in mysql appear at the top, first???

Good afternoon, I want to make it so that when entering a record in the database, it is displayed first (above) in the application. How to do this kind of sorting?

<FlatList
                        data={this.state.dataSource}
                        renderItem={({ item }) =>
                            <View style={styles.item}>
                                <Text style={styles.title}>
                                    <Text style={{backgroundColor: "#ff6a6a", padding: 5, color: '#fff', fontSize:10}}> {item.id} </Text>
                                    <Text>{item.title}</Text>
                                </Text>
                                <Image resizeMode="cover" source={{ uri: item.thumbnailUrl }} style={styles.imageView} />
                                <Text style={{padding: 5, color: '#737373',flex: 1}}>{item.announce}</Text>
                            </View>
                        }
                        keyExtractor={(item) => item.id.toString()}
                     />

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
ART4, 2020-07-15
@ART4

Made it easier, json sql output
ORDER BY `news_id` DESC

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question