更新时间:2021-11-29 22:47:13
是的,你可以检查空数组值,并可以使用这个来渲染另一个视图
Yes, you can check empty array value and can render another view by using this
{
(this.state.dataZ.length!=0)?
<FlatList
style={{ marginVertical: 20 }}
numColumns={2}
keyExtractor={(item, index) => index}
data={this.state.dataZ}
renderItem = {({ item }) => {
// console.log("Item in RenderItem : " + typeof item)
if(Array.isArray(this.state.dataZ)) {
return <MonatsView
navigate={() => this.props.navigation.navigate("Tag")}
tag={moment(item.activitydate).format("DD-MM")}
tagDesc={moment(item.activitydate).day()}
phase={item.phaseid}
time={item.time}
zkub={item.zkub}
/>
}
else {
return console.log("DATA IS NO ARRAY????")
}
}
}
/>
:
<View> .--------**write here any other view** ----- </View>
}
第 2 点:为此您可以使用:
Point 2: for this you can use:
使用部分列表只显示一个月的数据(https:///facebook.github.io/react-native/docs/sectionlist).
你应该根据月份来修改当前的数组对象,然后渲染一个视图并根据它进行设置.
you should modify the current array object according to months wise and render a view and set according to that.