反应原生异质部分列表

时间:2017-06-27 13:59:21

标签: react-native react-native-flatlist

有没有人有更详细的异构渲染示例 SectionLists?

<SectionList
  sections={[ // heterogeneous rendering between sections
      {data: [...], key: ..., renderItem: ...},
      {data: [...], key: ..., renderItem: ...},
      {data: [...], key: ..., renderItem: ...},
  ]}
/>

非常感谢!

1 个答案:

答案 0 :(得分:4)

以下是我如何能够为SectionLists实现异构呈现的示例摘录

所以这就是我的sectionsData数组看起来像

const sectionsData = { key: 'On Air', data: onAirShows, renderItem: ({item}) => <View><Text>{item}</Text></View> //This is what you want this particular section to look like }, { key: 'Off Air', data: offAirShows, renderItem: this._renderOffAirItems //Same thing for here. You can define it as a helper method and call it here like so }

<SectionList data={sectionsData} />

注意:onAirShowsoffAirShows是一个数组