Complete the code to import the SectionList component from React Native.
import { [1] } from 'react-native';
The SectionList component is used to render grouped lists in React Native.
Complete the code to define the sections prop with grouped data for SectionList.
const sections = [
{ title: 'Fruits', data: ['Apple', 'Banana'] },
{ title: 'Vegetables', data: ['Carrot', 'Peas'] }
];
<SectionList
sections=[1]
renderItem={({ item }) => <Text>{item}</Text>}
renderSectionHeader={({ section }) => <Text>{section.title}</Text>}
/>The sections prop expects an array of objects each with a title and data array.
Fix the error in the keyExtractor prop to uniquely identify each item.
<SectionList
sections={sections}
renderItem={({ item }) => <Text>{item}</Text>}
keyExtractor={(item, index) => item[1]index}
/>The keyExtractor should return a unique string. Concatenating the item with the index using '+' creates a unique key.
Fill both blanks to correctly render section headers with styling.
<SectionList
sections={sections}
renderItem={({ item }) => <Text>{item}</Text>}
renderSectionHeader={({ section }) => <Text style={{ [1]: 20, [2]: 'bold' }}>{section.title}</Text>}
/>The style uses fontSize to set text size and fontWeight to make text bold.
Fill all three blanks to complete the SectionList with sticky headers and a key extractor.
<SectionList
sections={sections}
stickySectionHeadersEnabled=[1]
keyExtractor={(item, index) => item + index.toString()}
renderItem={({ item }) => <Text>{item}</Text>}
renderSectionHeader={({ section }) => <Text style={{ fontWeight: [2], fontSize: [3] }}>{section.title}</Text>}
/>Sticky headers are enabled by setting stickySectionHeadersEnabled to true. The header text is bold with fontWeight 'bold' and fontSize 18.