2017-06-27 12 views
2

有没有人有更详细的异构渲染示例 SectionLists?React Native异源部分列表

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

非常感谢!

回答

2

下面是我如何已经能够实现对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是一个阵列

+0

在上面的例子中,如果没有数据从JSON传入第二节如何动态渲染节? –