deleteNewsComment = (id, commentid, commentKey) => {
return e => {
if (!isUndefined(e)) {
e.preventDefault();
}
modalConfirm(`<div>Удалить комментарий?</div>`, {
cancel: 'Отмена',
ok: 'Удалить'
}).then(() => {
NewsApi.deleteNewsComment(id, commentid).then(() => {
const {userComment} = this.state;
this.setState({userComment});
this.state.userComment.splice(commentKey, 1);
console.log(commentKey);
}).catch(() => {
});
}).catch(() => {
});
};
};
{_.map(singleNews.comments, (comment, commentKey) => {
if (comment.parentId === '00000000-0000-0000-0000-000000000000') {
return <CommentReply singleNews={singleNews}
userComment={comment}
commentKey={commentKey}
deleteNewsComment={this.deleteNewsComment( comment.id, singleNews.id, commentKey)}/>
}
}
)}
你好!谢谢您的关注!
为什么我无法捕获commentKey?
是否在日志中(未定义)?
为什么我的commentKey未定义?
另一个值id和commentid可以正常工作!