In the SectionList component, what are the roles of renderItem and renderSectionHeader?
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 ý: "renderItem receives an element from the data array of each individual section and renders a React Element, representing that item in the section." và "renderSectionHeader receives an element from the sections array to create and display the header for that section.". SectionList hiển thị danh sách chia nhóm: prop sections là mảng các đối tượng nhóm, mỗi nhóm có tiêu đề và mảng data riêng; renderItem được gọi cho từng phần tử trong data của từng nhóm, còn renderSectionHeader được gọi một lần cho mỗi đối tượng trong sections để vẽ tiêu đề nhóm. Phát biểu "receives an element directly from the data array (i.e., the data of all sections combined)" sai vì tiêu đề nhóm nhận đối tượng section chứ không nhận phần tử dữ liệu, và không có mảng gộp mọi nhóm. Phát biểu "Both props (renderItem and renderSectionHeader) receive an element from the sections array" sai vì hai prop nhận hai loại dữ liệu khác nhau và có vai trò khác nhau.