인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

sj p님의 프로필 이미지
sj p

작성한 질문수

따라하며 배우는 노드, 리액트 시리즈 - 유튜브 사이트 만들기

댓글은 생성이 되는데 대댓글 생성이 안 됩니다

작성

·

296

0

let renderReplyComment=(parentCommentId)=>{
        for (let i=0;i<8;i++){
            if (props.commentLists[i].responseTo === parentCommentId){
                console.log(props.commentLists[i].content)
            }
        }
        
        props.commentLists.map((comment,index)=>(
                       
            (comment.responseTo === parentCommentId && 
                <React.Fragment>
                    <div style={width: '80%'marginLeft: '40px' }}>
                        <SingleComment comment={comment} postId={props.videoId} refreshFunction={props.refreshFunction} />
                        <ReplyComment CommentLists={props.CommentLists} parentCommentId={comment._id} postId={props.videoId} refreshFunction={props.refreshFunction} />
                    </div>
                </React.Fragment>
            )
       ))

ReplyComment.js  코드 안에서서 대댓글을 생성하는 코드입니다.

위 함수에 아예 못 들어가는건가 싶어서 안에 for문으로 responseTo와 parentCommentID가 같을 경우 content log를 찍어봤는데 정확히 잘 나오는걸 확인했습니다.

그런데 대댓글 생성은 안됩니다.

아래가 제 실행 결과이고 그냥 댓글 생성은 되는것으로 보아 singleComment.js 파일은 문제가 없는거 같은데

대댓글이 생성 안 되는 이유를 모르겠습니다.

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
sj p님의 프로필 이미지
sj p

작성한 질문수

질문하기