【发布时间】:2019-08-27 12:45:09
【问题描述】:
下午好, 实际上我无法使用我的数组内容查看平面列表。数组正确添加数据,但 flatlist 不显示任何内容。另外,我想在数组的每一行上设置一个按钮到 flatlist 中。
数据“chosenDate”,是从数据选择器接收的数据(例如:“27 Agosto 2019 16:59”)并添加到数组中
感谢您的帮助。
var SampleArray = [];
export default class DateTimePickerTester extends Component {
handleDatePicked = date => {
this.setState({ chosenDate: moment(date).format('Do , MMMM YYYY HH:mm') });
SampleArray.push(this.state.chosenDate.toString())
console.log(SampleArray.toString());
};
FlatListItemSeparator = () => {
return (
<View
style={{
height: 1,
width: "100%",
backgroundColor: "#607D8B",
}}
/>
);
}
render() {
return (
<>
<FlatList
data={this.SampleArray}
keyExtractor={(item, index) => item.key}
renderItem={({ item, index }) => (
<TouchableHighlight>
<View style={{ backgroundColor: 'black' }}>
<Text>{item}</Text>
</View>
</TouchableHighlight>
)}></FlatList>
【问题讨论】:
标签: react-native react-native-flatlist