将 JSX 标签包裹在 renderItem 周围?对于<平面列表>或<节列表>在 React-Native 中节列表>平面列表>
有没有办法在 renderItem
周围放置 JSX 标签? (我想使用“react-native-paper”中的
将 renderItem
的渲染输出放入 Accordion 下拉列表中
<List.Accordion>
<FlatList
data={DATA}
renderItem={renderItem}
keyExtractor={item => item.id}
/>
</List.Accordion>
)但是,由于我使用的是 ListHeaderComponent
和 ListFooterComponent
道具;我只想要
围绕 renderItem
;这样 renderItem
的内容位于手风琴内部(作为容器),但不在页眉和页脚周围。
注意:我正在使用SectionList,但我制作了第一个示例 FlatList 来简化
我尝试了以下有效的方法;除了它不在
内渲染:
const AudioTracksScreenData = [
{
title: "Reviews",
renderItem: renderReviews,
data: audiobookReviewData.result,
keyExtractor: reviewsKeyExtractor,
},
]
<SectionList
sections={AudioTracksScreenData}
keyExtractor={({ section: { keyExtractor } }) => {
keyExtractor;
}}
renderItem={({ section: { renderItem } }) => (
<List.Accordion>{renderItem}</List.Accordion>
)}
ListHeaderComponent={getHeader()}
/>
- https://reactnative.dev/docs/flatlist
- https://reactnative.dev/docs/sectionlist
- https://callstack.github.io/react-native-paper/list-accordion.html
我可以使用
让它工作并且.map()
;不过,我希望有一种方法可以使用
来做到这一点。
我想要...(如果您按/单击评论,则会出现可折叠列表;忽略样式差异)
Is there a way to put JSX tags around renderItem
? (I want to put the rendered output from renderItem
inside an Accordion drop-down using <List.Accordion>
from "react-native-paper")
<List.Accordion>
<FlatList
data={DATA}
renderItem={renderItem}
keyExtractor={item => item.id}
/>
</List.Accordion>
This works; however as I am using a ListHeaderComponent
and ListFooterComponent
props; I only want the <List.Accordion>
around the renderItem
; so that the content of renderItem
are inside an accordion (as a container) but not around the header and footer.
Note: I am using SectionList, but I made the first example FlatList to simplify
I tried the following which works; except for it not rendering inside a <List.Accordion></List.Accordion>
:
const AudioTracksScreenData = [
{
title: "Reviews",
renderItem: renderReviews,
data: audiobookReviewData.result,
keyExtractor: reviewsKeyExtractor,
},
]
<SectionList
sections={AudioTracksScreenData}
keyExtractor={({ section: { keyExtractor } }) => {
keyExtractor;
}}
renderItem={({ section: { renderItem } }) => (
<List.Accordion>{renderItem}</List.Accordion>
)}
ListHeaderComponent={getHeader()}
/>
- https://reactnative.dev/docs/flatlist
- https://reactnative.dev/docs/sectionlist
- https://callstack.github.io/react-native-paper/list-accordion.html
I could get this to work using <ScrollView>
and .map()
; However I am hoping there is a way to do this with <SectionList>
.
What I want... (a collapsible list if you press/click on reviews; ignore styling differences)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论