Differentiate Scrol...
Differentiate Scrol...
In React Native, both ScrollView
and FlatList
are used to display scrollable content, but they serve different purposes and are optimized for different use cases. Here are the key differences between the two:
ScrollView
is a generic container that can hold multiple child components and allows them to be scrolled vertically or horizontally.import { ScrollView, Text, Image } from 'react-native';
const App = () => (
<ScrollView>
<Text>Header 1</Text>
<Image source={{ uri: 'https://example.com/image1.png' }} />
<Text>Header 2</Text>
<Image source={{ uri: 'https://example.com/image2.png' }} />
{/* More content */}
</ScrollView>
);
FlatList
is specifically designed to render a large list of similar items efficiently.senior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào