I am trying to get header name from renderItem but it giving me undefined. I need the name for a checklist so that's why I am trying to pass it to renderItem.
This is my code can anyone help me out?
const List = (props) => {
const list = [
{
"id": "G1600789684218",
"data": [
{
"id": "G1600789684218",
"value": "Going Skating",
},
],
"name": "Jack Ross",
}
]
const renderList = ({ item }, name) => {
console.log("item name is", name);
return (
<View>
<ListItem title={item.value} />
</View>
);
};
return (
<SectionList
sections={list}
keyExtractor={(item, index) => index}
renderSectionHeader={({ section: { name, data } }) =>
<Text style={styles.heading}>{name}</Text>
}
renderItem={renderList}
/>
);
};
export default List;
I think, your renderList should be like,