简体   繁体   English

React Native 异构节列表

[英]React Native Heterogenous Section List

Does anyone have a more elaborate example of heterogeneous rendering in SectionLists?有没有人在 SectionLists 中有更详细的异构渲染示例?

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

Help much appreciated!非常感谢帮助!

Here is an example snippet of how I've been able to implement the heterogeneous rendering for SectionLists这是我如何为 SectionLists 实现异构渲染的示例片段

So this is what my sectionsData array looks like所以这就是我的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}
/>

NOTE: The onAirShows and offAirShows is an array注意: onAirShowsoffAirShows是一个数组

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM