我正在尝试遍历数据源并基于该数据源显示Tabs
,并且我正在为此使用FlatList
,这是代码
<Tabs
renderTabBar={() => <ScrollableTab />}
tabBarUnderlineStyle={{backgroundColor: "#4285f4"}}
tabBarBackgroundColor="#fff"
>
<FlatList
data={this.state.dataSource}
renderItem={({item}) =>
<Tab
heading={item.title}
>
<Text>Tab details</Text>
</Tab>
/>
</Tabs>
这总是给我一个错误的说法
undefined is not an object (evaluating 'child.props.heading.props') the error is located at ScrollableTabView
我不知道我尝试使用map
而不是FlatList
出了什么问题,并且工作正常
您必须用]替换本机基本选项卡组件>
https://github.com/ptomasroos/react-native-scrollable-tab-view/blob/master/README.md。
无需使用Flatlist作为子组件以获得更好的性能,它将无法正常工作。