• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

또.. 질문입니다 ㅎㅎㅎㅎ...

20.05.08 22:12 작성 조회수 98

0

질문이 많아서 죄송하네요 ㅠ.ㅠ

코멘트를 랜더하는 코드에서 

중괄호를 써서 함수를 만들면 (두번째 코드)

랜더가 안되더라구요

중괄호가 들어가는 것과 들어가지 않은것이 무슨 차이가 있는지 궁금합니다 

궁금한게 많은것 같아서 죄송하네요 ㅠ.ㅠ.

let renderReplyComment = (parentCommentId=>
    props.commentLists.map((commentindex=> (
      <React.Fragment>
        {comment.responseTo === parentCommentId && (
          <div style={{ width: "80%", marginLeft: "40px" }}>
            <SingleComment
              key={index}
              refreshFunction={props.refreshFunction}
              comment={comment}
              postId={props.postId}
            />
            <ReplyComment
              parentCommentId={comment._id}
              refreshFunction={props.refreshFunction}
              postId={props.postId}
              commentLists={props.commentLists}
            />
          </div>
        )}
      </React.Fragment>
    ));
=====================================================
  
let renderReplyComment = (parentCommentId=> {
    props.commentLists.map((commentindex=> (
      <React.Fragment>
        {comment.responseTo === parentCommentId && (
          <div style={{ width: "80%", marginLeft: "40px" }}>
            <SingleComment
              key={index}
              refreshFunction={props.refreshFunction}
              comment={comment}
              postId={props.postId}
            />
            <ReplyComment
              parentCommentId={comment._id}
              refreshFunction={props.refreshFunction}
              postId={props.postId}
              commentLists={props.commentLists}
            />
          </div>
        )}
      </React.Fragment>
    ));
  };

답변 2

·

답변을 작성해보세요.

1

안녕하세요 릴롱궤님  ㅎㅎㅎ 
친구가 된것 같네요 ㅎ 

중괄호를 하면 return 으로   표현해줄부분을 출력해주셔야   화면에 보이게 되고 

아니면  지금처럼 아예 중괄호를 없애 주시거나   ()   이걸로 감싸주셔도 됩니다 ^^ 

0

릴롱궤님의 프로필

릴롱궤

질문자

2020.05.10

감사합니다!