Which of the following characteristics are true when talking about the FlatList component in React Native?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng gồm hai ý: "FlatList only renders the items currently visible on the screen, improving performance by reducing the number of components rendered at the same time." và "FlatList will render each item in the data array using the renderItem prop, allowing you to customize how each item is displayed." FlatList là danh sách ảo hoá: nó chỉ dựng các phần tử trong và gần vùng nhìn thấy rồi dựng tiếp khi cuộn, nên số component tồn tại cùng lúc nhỏ; mỗi phần tử của mảng data được truyền vào hàm renderItem (nhận item và index) để ta quyết định giao diện từng dòng. Phát biểu "automatically groups data based on the key if you do not provide the keyExtractor prop" sai vì FlatList không gom nhóm dữ liệu (chia nhóm là việc của SectionList); thiếu keyExtractor nó chỉ lấy item.key, rồi tới index, làm khoá. Phát biểu "FlatList requires you to pass a children prop to display the items." sai vì FlatList không dùng children mà dùng cặp data và renderItem.