인프런 커뮤니티 질문&답변
안녕하세요.
작성
·
257
답변 3
2
John Ahn
지식공유자
안녕하세요
<span onClick={() => onDeleteComment(props.comment._id)}><Icon type="delete" /></span>
클릭하실때 comment의 아이디를 이용하셔서
const onDeleteComment = (targetedCommentId) => {
let confirmRes = window.confirm('정말 이 글을 삭제하시길 원하시나요 ?');
if (confirmRes) {
const variables = {
commentId: targetedCommentId
}
Axios.post(``, variables)
.then(response => {
if (response.data.success) {
props.refreshDeleteFunction(response.data.deletedCommentId)
} else {
alert('댓글 지우기를 실패 했습니다.')
}
})
}
}
이런식으로 해주셔도 됩니다. ~
0
0





