constructor(props){
super(props);
this.state = {
noteArray: [],
noteText: '',
dateText: '',
}
}
addList() {
if (this.state.noteText){
let d = new Date();
this.state.noteArray.push({
date : new Date(this.state.dateText),
note : this.state.noteText
});
this.setState({ noteArray: this.state.noteArray, noteText: "", dateText: ""});
}
}
deleteLi(key){
this.state.noteArray.splice(key, 1);
this.setState({noteArray: this.state.noteArray})
}
editingLi(key){
this.setState({
noteText: this.state.noteArray[key].note,
dateText: this.state.noteArray[key].date
})
}
render() {
let notes = this.state.noteArray.map((val, key) => {
return <ListItens key ={key} keyval={key} val={val}
deleteMethod={ () => this.deleteLi(key) }
onEditing ={ () => this.editingLi(key)}
updateItens={ () => this.updateLi(key)}/>
});
当我打开时按下编辑按钮
editMethod(){
if(this.props.isEditing) {
this.handleSubmit ()
}
else {
!this.props.onEditing || this.props.onEditing()
}
}
任务上的文本和日期返回到TextInput和DatePicker。但是编辑后,我无法将更新索引发送回我的任务。
我希望添加任务的同一按钮也可以在更新它们之后将它们发送回去。
我该怎么办?