Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ItemSeparatorComponent - Call back for each row

Tags:

react-native

How do I make ItemSeparatorComponent prop of FlatList get called for each row, so that one can customize for each row. Something similar of what renderSeparator prop of deprecated ListView.

like image 519
com.iavian Avatar asked May 07 '17 11:05

com.iavian


1 Answers

I had the same requirement, turns out you can pass a function as well:

renderSeparator = ({leadingItem, section})=>{
  if (section.noSeparator || !leadingItem.noSeparator)
    return null;
  return <Separator />;
};

render(){
  return <SectionList
      renderSectionHeader={this.renderSectionHeader}
      sections={this.sections}
      renderItem={this.renderItem}
      ItemSeparatorComponent={this.renderSeparator}
  />;
}
like image 128
Gilad Novik Avatar answered Nov 15 '22 11:11

Gilad Novik